首页 >后端开发 >php教程 > 如何把一维数组相结合

如何把一维数组相结合

WBOY
WBOY原创
2016-06-13 13:00:09983浏览

怎么把一维数组相结合
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