<?php //two-D array transpose //define a two-dimensional array $arr =array (Array (), Array (4,5,6)); Defines an array to place the transpose data $arr 1=array (); Traverse Echo before transpose "before transpose:"; for ($i =0; $i <count ($arr), $i + +) {for ($j =0; $j <count ($arr [$i]); $j + +) { echo $arr [$i]; } echo ""; } echo "Transpose before and after:"; Determine the number of lines after the appliance for ($j =0; $j <count ($arr [0]), $j + +) { $arr 1[$j]=array (); } for ($i =0; $i <count ($arr), $i + +) {for ($j =0; $j <count ($arr [$i]); $j + +) { $arr 1[$j] [$i]= $arr [$i] [$j]; echo $arr; } } Traverse after transpose: for ($k =0; $k <count ($arr 1); $k + +) {for ($l =0; $l
The above introduces PHP multidimensional array php Two-dimensional array of the rectangle transpose, including the contents of the PHP multidimensional array, I hope that the PHP tutorial interested in a friend helpful.