字符串翻转
<?php //字符串翻转 function myrev($str) { $arr = explode(' ', $str); $num = count($arr); for ($i = 0; $i < $num / 2; ++$i) { $temp = $arr[$i]; $arr[$i] = $arr[$num - $i - 1]; $arr[$num - $i - 1] = $temp; } return implode(' ', $arr); } $str = 'This is PHP'; echo myrev($str); //PHP is This echo strrev($str); //PHP si sihT
希望广大博友给予建议和指导