Subject: PHP

Split Array into Chunks

Write a PHP function to split an array into chunks of a given size without using array_chunk().

Example:
Input: Array: [1, 2, 3, 4, 5, 6], Size: 2
Output: [[1, 2], [3, 4], [5, 6]]

Select file or drag and drop

PNG, JPG, SVG

Preview