Creating Multidimensional Arrays
<?php
$customers= array(
array('first' => 'Bill', 'last' => 'Jones',
'age' => 24, 'state' => 'CA'),
array('first' => 'Joyce', 'last' => 'Johnson',
'age' => 21, 'state' => 'TX'),
);
$pet_breeds= array(
'dogs' => array('P', 'T', 'D'),
'birds' => array('P', 'C'),
'fish' => array('G', 'T', 'C', 'A')
);
printf("<p>The name of the second customer is %s %s.</p>\n",
$customers[1]['first'], $customers[1]['last']);
printf("<p>%s and %s</p>",
$pet_breeds['dogs'][0], $pet_breeds['birds'][1]);
?>
Related examples in the same category