The example in this paper describes the PHP implementation of converting a one-dimensional array into a two-dimensional array of 3 consecutive values. Share to everyone for your reference, as follows:
<?PHP$AAA = Array (' AA ', ' 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 results of the operation are 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 3 groups, if 2 is 2 a group
More about PHP related content readers can view this site topic: "PHP array" operation Skills Daquan, "PHP Sorting algorithm Summary", "PHP common traversal algorithm and skills summary", "PHP Data structure and algorithm tutorial", "PHP Programming Algorithm Summary", " PHP Math Skills Summary, "PHP Regular Expression Usage summary", "PHP Operations and Operator Usage Summary", "PHP string Usage Summary" and "PHP common database Operation Skills Summary"
I hope this article is helpful to you in PHP programming.
The above describes the PHP conversion of a one-dimensional array into a two-dimensional array of 3 consecutive values, including the two-dimensional array, PHP content, I hope to be interested in PHP tutorial friends helpful.