phpposixdeprecatedpcrealternate

Alternative function for php deprecated sql_regcase()


i have the code bellow:

foreach($filetypes as $filetype)
{
  $filenum = $filenum + count(glob($root.$tree.$branch.sql_regcase($filetype),GLOB_NOSORT));
}

Function sql_regcase() is deprecated. Does anyone know an alternative for sql_regcase() ? I have tried this below but i think it's not the same.

$filenum = $filenum+count(glob($root.$tree.$branch.preg_mach("/$filetype/ig"),GLOB_NOSORT));

Also according to this http://php.net/manual/en/reference.pcre.pattern.posix.php there is No equivalent function.


Solution

  • Finally, i made it:

    function my_Sql_regcase($str){
    
        $res = "";
    
        $chars = str_split($str);
        foreach($chars as $char){
            if(preg_match("/[A-Za-z]/", $char))
                $res .= "[".mb_strtoupper($char, 'UTF-8').mb_strtolower($char, 'UTF-8')."]";
            else
                $res .= $char;
        }
    
        return $res;
    }