PHP array_chunk() Function

The array_chunk() function is used to split an array into arrays with size elements. The last chunk may contain less than size elements.It chunks an array into size large chunks. The last chunk may contain less than size elements.

Example -

Example -

In the following example, we set preserve_keys as TRUE, therefore, array_chunk function preserves the original array keys.

Example -