颠倒字符串中空格分隔的单词的顺序

2022-04-17 00:00:00 string reverse php

颠倒字符串中以空格分隔的单词顺序的最佳方法是什么?

Hello everybody in stackoverflow

变为

stackoverflow in everybody Hello

解决方案

试试:

$s = 'Hello everybody in stackoverflow';
echo implode(' ', array_reverse(explode(' ', $s)));

相关文章