Home > Article > Backend Development > How to define a two-dimensional array in php
How to define a two-dimensional array in php?
The values in one array can be another array, and the values in another array can also be an array. In this way, we can create a two-dimensional or three-dimensional array:
The code example is as follows:
<?php // 二维数组: $cars = array ( array("Volvo",100,96), array("BMW",60,59), array("Toyota",110,100) ); print_r($cars); ?>
Output:
Array ( [0] => Array ( [0] => Volvo [1] => 100 [2] => 96 ) [1] => Array ( [0] => BMW [1] => 60 [2] => 59 ) [2] => Array ( [0] => Toyota [1] => 110 [2] => 100 ) )
For more PHP knowledge, please visit PHP中文网!
The above is the detailed content of How to define a two-dimensional array in php. For more information, please follow other related articles on the PHP Chinese website!