本文實例講述了php簡單實現(xiàn)多字節(jié)字符串翻轉(zhuǎn)的方法。分享給大家供大家參考。具體實現(xiàn)方法如下:
<?php
function mb_strev ($string, $encoding = null) {
if ($encoding === null) {
$encoding = mb_detect_encoding($string);
}
$length = mb_strlen($string, $encoding);
$reversed = '';
while($length-- > 0) {
$reversed .= mb_substring($string, $length, 1, $encoding);
}
return $reversed;
}
更多信息請查看IT技術(shù)專欄