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>
The above has introduced [php function]--array function--array_chunk, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.