Php-Arrays function-chunk-splits an array into multiple Arrays. Chunk () function [function] This function splits an array into multiple arrays, the size of the number of units in each array determines the number of units in the last array. it may be several fewer chunk () functions.
[Function]
This function splits an array into multiple arrays,
The number of units in each array is determined by the size.
The number of units in the last array may be smaller.
The obtained array is a unit in a multi-dimensional array, and its index starts from scratch.
Scope of use]
> = 4.2.0, php5
[Use]
Array array_chunk (array input, int size [, bool preserve_keys])
Input/required/split array
Size/required/Number of units in the array
Preserve_keys/optional/True reserve the original key name of the array,
The value of the False key is a numeric index starting from scratch. the default value is False.
[Example]
[Php]
$ Arr = array ("key1" => "val1", "key2" => "val2 ",
"Key3" => "val3", "key4" => "val4 ");
Print_r (array_chunk ($ arr, 2 ));
Print_r (array_chunk ($ arr, 2, True ));
Print_r (array_chunk ($ arr, 3 ));
/*
Array
(
[0] => Array
(
[0] => val1
[1] => val2
)
[1] => Array
(
[0] => val3
[1] => val4
)
)
Array
(
[0] => Array
(
[Key1] => val1
[Key2] => val2
)
[1] => Array
(
[Key3] => val3
[Key4] => val4
)
)
Array
(
[0] => Array
(
[0] => val1
[1] => val2
[2] => val3
)
[1] => Array
(
[0] => val4
)
)
*/
Taken from zuodefeng's note
Http://www.bkjia.com/PHPjc/478197.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/478197.htmlTechArticlechunk () function [function] This function splits an array into multiple arrays, the size of the number of units in each array determines the number of units in the last array...