我正在尝试找到一种反转字符串的方法。虽然我看过其他方法,但我希望通过独立思考并不使用任何其他人的代码来完成这个任务。以下代码可以将字符串反转,但是我一直收到如下错误提示:
注意:C:\wamp\www\test\index.php第15行中未定义偏移量:25。
其中25是被递减的字符串长度。
感谢您提前答复。
注意:C:\wamp\www\test\index.php第15行中未定义偏移量:25。
其中25是被递减的字符串长度。
//error_reporting(NULL);
$string = trim("This is a reversed string");
//find length of string including whitespace
$len =strlen($string);
//slipt sting into an array
$stringExp = str_split($string);
//deincriment string and echo out in reverse
for ($i = $len; $i >=0;$i--)
{
echo $stringExp[$i];
}
感谢您提前答复。