Previous | Home | Next |
array_chunk()
The array_chunk() function splits an array into chunks of new arrays.
Syntax:array_chunk(array,size,preserve_key);
In above syntax, "array" specifies the array to use, "size" is an integer that specifies the size of each chunk and "preserve_key" preserve_key values are as follows:
- true: Preserves the keys
- false: Default and reindexes the chunk numerically
Example:
<?php $fruit_weight=array("Apple"=>"5kg","Banana"=>"7kg","Mango"=>"10kg"); print_r(array_chunk($fruit_weight,2)); ?>
Output:
Previous | Home | Next |