← All built-ins / array_chunk()
array_chunk()
array_chunk(...$args): mixed
Parameters
| Name | Type | Description |
|---|---|---|
| $a | array | input array |
| $size | int | maximum chunk size |
Return value
Array of arrays, each with at most $size elements.
Example
$c = array_chunk([1, 2, 3, 4, 5], 2);
echo count($c), " ", implode(",", $c[2]);3 5