StrRev() Dosent Support UTF-8

in order to make that strrev() support UTF-8 you need to use this Function

function utf8_strrev($str){
    preg_match_all('/./us', $str, $ar);
    return join('', array_reverse($ar[0]));
}

so we going to chage strrev() in our code to utf8_strev() :

$string = "اهلا بك";
echo "$string <br>";
$Reversed = utf8_strrev($string); // here we have changed it
echo "<br><b>After Reverse</b><br><br>";
echo "<br> $Reversed";

and the Result is :

اهلا بك

After Reverse


كب الها

I have been using this one

taken from here http://php.net/manual/en/function.strrev.php#122953

function mb_strrev($str){
    $r = '';
    for ($i = mb_strlen($str); $i >= 0; $i--) {
        $r .= mb_substr($str, $i, 1);
    }

    return $r;
}