Learning PHP and MySQL

Example 06-07 Creating a multidimensional array

<?php
$objects
=array('Soda Can' => array('Shape' => 'Cylinder',
                                    
'Color' =>  'Red',
                                    
'Material' => 'Metal'),
               
'Note Pad' => array('Shape' => 'Rectangle',
                                   
'Color' => 'White',
                                   
'Material' => 'Paper'),
               
'Apple' => array('Shape' => 'Sphere',
                                
'Color' => 'Red',
                                
'Material' => 'Fruit'),
               
'Orange' => array('Shape' => 'Sphere',
                                 
'Color' => 'Orange',
                                 
'Material'  =>  'Fruit'),
               
'Phonebook' => array('Shape' => 'Rectangle',
                                    
'Color' => 'Yellow',
                                    
'Material' => 'Paper'));
echo 
$objects['Soda Can']['Shape'];
?>

Posted by on 08/07 at 10:23 AM

Next entry: Example 06-08 Displaying a multidimensional array

Previous entry: Example 06-06 Using sort to alphabetize

<< Back to main