<?php
$array = array( 'a', 'b', 'c', 'd', 'e', 'f', 'g' );
$array2 = array_chunk( $array, 3 );
$array3 = array_chunk( $array, 3, TRUE );
var_dump( $array2 );
var_dump( $array3 );
/*output:
array(3) {
[0]=> array(3) {
[0]=> string(1) "a"
[1]=> string(1) "b"
[2]=> string(1) "c"
}
[1]=> array(3) {
[0]=> string(1) "d"
[1]=> string(1) "e"
[2]=> string(1) "f"
}
[2]=> array(1) {
[0]=> string(1) "g"
}
}
array(3) {
[0]=> array(3) {
[0]=> string(1) "a"
[1]=> string(1) "b"
[2]=> string(1) "c"
}
[1]=> array(3) {
[3]=> string(1) "d"
[4]=> string(1) "e"
[5]=> string(1) "f"
}
[2]=> array(1) {
[6]=> string(1) "g"
}
}
*/
?>
|