I'm testing some php features on string but it doesn't work.
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.
Can you give me a clue?
Thanks a lot.
Sorry for the English, I'm French.
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]);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.