Array_chunk function

Array_chunk function

This function is used to split an array into chunks

array array_chunk ( array input, int size [, bool preserve_keys])
Example :

$array1 = array(’aaaa’, ‘bbbb’, ‘cccc’, ‘dddd’, ‘eeee’);

print_r(array_chunk($input_array, 3));

print_r(array_chunk($input_array, 3, TRUE));

//Result

Array ( [0] => Array ( [0] => aaaa [1] => bbbb [2] => cccc ) [1] => Array ( [0] => dddd [1] => eeee ) )

Array ( [0] => Array ( [0] => aaaa [1] => bbbb [2] => cccc ) [1] => Array ( [3] => dddd [4] => eeee ) )

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.