如果我有输入:
$input = "One Two Three";
我如何将第一个单词与第三个单词交换并输出:
"Three Two One"
答案 0 :(得分:1)
这是你的答案。
xx_xxxx__x xxxxxxxxxx
xxxxx_xxxx xxxxxxxxxx
xx__xxxxxx xxxxxxxxxx
xxxxxxxxx_ xxx_______
答案 1 :(得分:1)
试试这个:
$input = "One Two Three";
$words = str_word_count($input, 1);
$reversed_words = array_reverse($words);
print_r($reversed_words); // prints Array ( [0] => Three [1] => Two [2] => One )
创建字符串:
$input = implode(' ', $reversed_words);
echo $input; // "Three Two One"