为什么 PHP 函数 strrev() 一会儿不起作用?
我正在测试字符串上的一些 php 功能,但它不起作用。
这是我的代码:
$string = "L'eau est claire.";
$string2 = explode(' ', $string);
$count = count($string) - 1;
while ($i <= $count)
{
strrev($string2[$i]);
$i++;
}
$string3 = implode (' ', $string2);
echo $string3;
我尝试了 strrev
函数,它确实有效。
你能给我一个线索吗?
非常感谢。
对不起英语,我是法国人。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
函数
strrev
不会修改中的字符串place - 它返回一个新字符串。在您的代码中,您没有使用strrev
的结果 - 您正在调用该函数,然后丢弃结果。你需要在这里做一个作业:The function
strrev
doesn't modify the string in place - it returns a new string. In your code you aren't using the result ofstrrev
- you are calling the function and then discarding the result. You need an assignment here: