Page 117 - Open Soource Technologies 304.indd
P. 117
Open Source Technologies
Notes Multidimensional Arrays
In a multidimensional array, each element in the main array can also be an array. And each
element in the sub-array can be an array, and so on.
Example: 1. In this example we create a multidimensional array, with automatically
assigned ID keys:
$families = array
(
“Griffin”=>array
(
“Peter”,
“Lois”,
“Megan”
),
“Quagmire”=>array
(
“Glenn”
),
“Brown”=>array
(
“Cleveland”,
“Loretta”,
“Junior”
)
);
The array above would look like this if written to the output:
Array
(
[Griffin] => Array
(
[0] => Peter
[1] => Lois
[2] => Megan
)
[Quagmire] => Array
(
[0] => Glenn
)
[Brown] => Array
(
112 LOVELY PROFESSIONAL UNIVERSITY