【发布时间】:2017-08-28 14:41:40
【问题描述】:
我想在第一行打印字符串数组的前两个名称,在下一行打印剩余的名称。
<?php
$array = array("johnny bairstow alex hales jonh marush","Marcelo nash tim pane alexender","chaudary Mian
Muhammad Aqeel shaib ");
for ($i=0; $i < count($array) ; $i++) {
$len = strlen($array[$i]);
$string = $array[$i];
for ($j = 8; $j < 9 ; $j++) {
$string[$j] ='\n';
}
echo $string."</br>";
}
?>
输出应该是:
johnny doe
alex hales jonh marush
Marcelo Nash
tim pane alexender
chaudary Mian
Muhammad Aqeel shaib
【问题讨论】:
-
johny doe 可能是 johny bairstow..
-
如果数组中的第一个字符串只包含 3 个单词而不是 4 个单词,输出会是什么?