Home >Backend Development >PHP Tutorial >怎么写一段函数实现字符串的翻转?只改变单词顺序,不要所有字母倒序

怎么写一段函数实现字符串的翻转?只改变单词顺序,不要所有字母倒序

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-13 12:05:371306browse

如何写一段函数实现字符串的翻转?只改变单词顺序,不要所有字母倒序!
如何将字符串倒序,如"I love you" 变成"you love I",只翻转句子顺序,不翻转字母的?
------解决方案--------------------

$string="I love you";<br />echo implode(array_reverse(explode(" ",$string))," ");

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn