开发者

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.

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]);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜