Creating Multidimensional Arrays : Multidimensional Array « Data Structure « PHP






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

1.Reference element in multidimensional Arrays
2.Defining a Multidimensional Array
3.Looping Through a Multidimensional Array
4.Displaying a Multidimensional Array using For each
5.Accessing multidimensional array elements
6.Creating a Multidimensional Array
7.Sorting Multidimensional Arrays
8.Multidimensional array element value interpolation
9.Displaying Multidimensional Arrays
10.Displaying a multidimensional array
11.Find the Maximum Value in a Multidimensional Array
12.Generating fixed-width field data records without
13.Manipulating multidimensional arrays