Multidimensional Array Is an array containing one or
more array.We can create two dimensional
array, three dimensional array and n dimensional array using array function.
Each array within the multidimensional array can either index array or
associative array. We can use for loop for looping through indexed array and
foreach for looping through associative array in multidimensional array.Making in multidimensional in
the way it can store multiple sets of Key=>
value pairs.
Syntax: $arrayDemo=array(“value1=>”array(value1,value2,
value3), “value2=>”array(value1,value2, ), “value3=>”array(value1,value2,
value3));
Program 1
<html>
<body>
<?php
$family=array("aman"=>array("abc","zxc"),"deepu"=>array("rose","rajni"));
echo "family of
aman".$family["aman"][1];
?>
</body>
</html>
Program 2
<html>
<body>
<?php
$products = array(
'paper' => array(
'copier' => "Copier
& Multipurpose",
'inkjet' => "Inkjet
Printer",
'laser' => "Laser
Printer",
'photo' =>
"Photographic Paper"),
'pens' => array(
'ball' => "Ball
Point",
'hilite' => "Highlighters",
'marker' =>
"Markers"),
'misc' => array(
'tape' => "Sticky
Tape",
'glue' =>
"Adhesives",
'clips' =>
"Paperclips") );
echo "<pre>";
foreach ($products as
$section => $items)
foreach ($items as $key =>
$value)
echo
"$section:\t$key\t($value)<br>";
echo
"</pre>";
echo
sort($products,SORT_STRING);
?>
</body>
</html>
Here video Tutorial