Why strrev() php function doesn't work in a while?
I'm testing some php features on string but it doesn't work.
开发者_JAVA技巧This is my code:
$string = "L'eau est claire.";
$string2 = explode(' ', $string);
$count = count($string) - 1;
while ($i <= $count)
{
strrev($string2[$i]);
$i++;
}
$string3 = implode (' ', $string2);
echo $string3;
I tried the function strrev
out the while and it does work.
The function strrev
doesn't modify the string in place - it returns a new string. In your code you aren't using the result of strrev
- you are calling the function and then discarding the result. You need an assignment here:
$string2[$i] = strrev($string2[$i]);
精彩评论