Search code snippets, questions, articles...

Split array into chunks using array_chunk() PHP

Breaking array into chunks of given size value.
    //IN CHUNKS OF 2
    $subjects = array("Math","Physics","Chemistry","English");
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place. Check how cool is the tool

PHP inbuilt function array_chunk() can be used to split the array into chunks of given size value.


array_chunk($array, $size, hold_keys)

Search Index Data (The code snippet can also be found with below search text)

array_chunk() function PHP
Was this helpful?