This function support utf-8 encoding
function utf8_strrev($str){
preg_match_all('/./us', $str, $ar);
return join('',array_reverse($ar[0]));
}
(PHP 4, PHP 5, PHP 7)
strrev — Reverse a string
$string
)
Returns string, reversed.
stringThe string to be reversed.
Returns the reversed string.
Example #1 Reversing a string with strrev()
<?php
echo strrev("Hello world!"); // outputs "!dlrow olleH"
?>
This function support utf-8 encoding
function utf8_strrev($str){
preg_match_all('/./us', $str, $ar);
return join('',array_reverse($ar[0]));
}