Home > Backend Development > PHP Tutorial > 如何把一维数组相结合

如何把一维数组相结合

WBOY
Release: 2016-06-13 13:00:09
Original
971 people have browsed it

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

把元素三个组成一个

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

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

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template