A two-dimensional array. php: php converts a one-dimensional array to a two-dimensional array consisting of three consecutive values: this example describes how php converts a one-dimensional array to a two-dimensional array consisting of three consecutive values. For your reference, the running result is as follows: Array (this example describes how php converts a one-dimensional Array to a two-dimensional Array consisting of three consecutive values. We will share this with you for your reference. The details are as follows:
<? Php $ aaa = array ('A', 'BB ', 'CC', 'DD', 'ee', 'FF ', 'GG', 'hh ', 'II'); for ($ I = 0; $ I <3; $ I ++) {$ bbb [] = array_slice ($ aaa, $ I * 3, 3) ;}print_r ($ bbb) ;?>
The running result is as follows:
Array ([0] => Array ([0] => aa [1] => bb [2] => cc) [1] => Array ([0] => dd [1] => ee [2] => ff) [2] => Array ([0] => gg [1] => hh [2] => ii ))
Key code:
$ Bbb [] = array_slice ($ aaa, $ I * 3, 3); // 3 is a group of three. if it is a group of two, 2 is a group of two.