我知道这有点奇怪,但我需要这个来完成我的任务。
我想将前两个单词移到后面的两个单词中,例如在我的(错误)代码中:
<?
$sentence = "zero one two three four five six seven eight";
$sentence2 = explode (" ",$sentence);
$total = count($sentence2);
for ($i = 4; $i < $total; ++$i) {
$result = $sentence2[2]." ".$sentence2[3]." ".$sentence2[0]." ".$sentence2[1]." ".$sentence2[$i];
}
echo "Original sentence : ".$sentence;
echo "<br>Result : ".$result;
?>
但该代码的结果不是我想要的,结果是
two three zero one eight
我想要结果:
two three zero one four five six seven eight
你能帮我写一个更好的代码吗?