Home > PHP > Function > Arrays > array_chunk()

array_chunk()

array_chunk - Split an array into chunks

Syntax

array array_chunk (array $input, int $size, bool $preserve_keys)

Arguments

  • input - The array to work on
  • size - The size of each chunk
  • preserve_keys - When set to TRUE keys will be preserved. Default is FALSE which will reindex the chunk numerically

Description

Chunks an array into size large chunks. The last chunk may contain less than size elements.

Version

PHP 4.2.0, 5

Return value

Returns a multidimensional numerically indexed array, starting with zero, with each dimension containing size elements.