array_chunk
array_chunk(array $input, int $size, [, bool $preserve_keys=false])
<code><span>$input</span>=<span>array</span>(<span>"a"</span>=><span>"php"</span>,<span>"b"</span>=><span>"c"</span>,<span>"c"</span>=><span>"c++"</span>,<span>"d"</span>=><span>"python"</span>,<span>"e"</span>=><span>"ruby"</span>); <span>$output</span> = array_chunk(<span>$input</span>, <span>2</span>); <span>#output=></span><span>Array</span> ( [<span>0</span>] => <span>Array</span> ( [<span>0</span>] => php [<span>1</span>] => c ) [<span>1</span>] => <span>Array</span> ( [<span>0</span>] => c++ [<span>1</span>] => python ) [<span>2</span>] => <span>Array</span> ( [<span>0</span>] => ruby ) ) <span>$output2</span> = array_chunk(<span>$input</span>, <span>2</span>, <span>true</span>); <span>#output2=> </span><span>Array</span> ( [<span>0</span>] => <span>Array</span> ( [a] => php [b] => c ) [<span>1</span>] => <span>Array</span> ( [c] => c++ [d] => python ) [<span>2</span>] => <span>Array</span> ( [e] => ruby ) ) <span>#注意子数组中的key还是保留原来数组中的key</span></code>
以上就介绍了[php函数]--数组函数--array_chunk,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。