The values in one array can be another array, and the values in another array can be an array. In this way, we can create two- or three-dimensional arrays:
<?php // two-dimensional array: $cars = array ( array ( " Volvo " , 100 , 96 ) , array ( " BMW " , 60 , 59 ) , array ( " Toyota " , 110 , 100 ) ) ; ?>
A multidimensional array is an array that contains one or more arrays.
In a multidimensional array, each element in the main array can also be an array, and each element in the subarray can also be an array.
In this example, we create a multidimensional array with automatically assigned ID keys:
<?php$sites = array( "codercto" =>array ( "Coder Tutorial" , "http://www.codercto.com" ), "google" =>array ( "Google Search" , "http:/ /www.google.com" ), "taobao" =>array ( "Taobao" , "http://www.taobao.com" ));print( "<pre>" ); // Formatted output array print_r ( $sites );print( "</pre>" ); ?>
Let's try to display a value from the above array:
echo $sites['codercto'][0] . 'The address is:' . $sites['codercto'][1];