PHP
php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php
//Multidimensional Array
// Simply an array of array. Subarray can also include another array. Lets see example.
$continents = array("Asia"=>array("Bangladesh","India","Pakistan"),
"Europe"=>array("England","France"),
"Africa"=>array("Kenya","Libya","Somalia"));
echo '<pre>';
//to access and view elements of multidimensional array we need to use foreach and foreach creates only for array. If you put foreach for other var such as int, string etc. except object then it will issue an error.
//now see first element of every array
foreach ($continents as $subcontinents){
print $subcontinents[0].'<br/>';
}
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run