Be careful, it does not work with unicode strings.
<?php
php > $str = '1¥';
php > print($str);
1¥
php > print(strrev($str));
��1
?>
(PHP 4, PHP 5, PHP 7)
strrev — 文字列を逆順にする
$string
)
string
を逆順にして返します。
string
逆順にしたい文字列。
逆順にした文字列を返します。
例1 strrev() で文字列を逆順にする
<?php
echo strrev("Hello world!"); // 出力は "!dlrow olleH" となります
?>
Be careful, it does not work with unicode strings.
<?php
php > $str = '1¥';
php > print($str);
1¥
php > print(strrev($str));
��1
?>
This function support utf-8 encoding
function utf8_strrev($str){
preg_match_all('/./us', $str, $ar);
return join('',array_reverse($ar[0]));
}