首頁 >後端開發 >php教程 > 如何把一维数组相结合

如何把一维数组相结合

WBOY
WBOY原創
2016-06-13 13:00:09984瀏覽

怎么把一维数组相结合
array("你好","这里","太好了","设置","帮助","他人","答案")

把元素三个组成一个

array("你好这里太好了","设置帮助他人","答案")
------解决方案--------------------

$ar = array("你好","这里","太好了","设置","帮助","他人","答案");<br />
foreach(array_chunk($ar, 3) as $v) $r[] = join('', $v);<br />
print_r($r);
Array<br />
(<br />
    [0] => 你好这里太好了<br />
    [1] => 设置帮助他人<br />
    [2] => 答案<br />
)<br />

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn