萬盛學電腦網

 萬盛學電腦網 >> 網絡編程 >> php編程 >> php簡單實現多字節字符串翻轉的方法

php簡單實現多字節字符串翻轉的方法

 本文實例講述了php簡單實現多字節字符串翻轉的方法。分享給大家供大家參考。具體實現方法如下:

1 2 3 4 5 6 7 8 9 10 11 12 <?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; }
copyright © 萬盛學電腦網 all rights reserved