字符串翻转
时间:2011-04-21 来源:高华
1 function str_reverse($str){
2 $r = array();
3 $result = '';
4 $encode = mb_detect_encoding($str, array('UTF8','GBK'));
5 $len=mb_strlen($str, $encode);
6 for($i=0;$i<$len;$i++){
7 $r[] = mb_substr($str,$i,1,$encode);
8 }
9 while(($tmp = array_pop($r)) !== NULL){
10 $result .= $tmp;
11 }
12 return $result;
13 }
14 echo str_reverse('360安全卫士');
相关阅读 更多 +