Multidimensional Array

You can think of a multidimensional array as an array of arrays. This means that every element in the array holds a sub-array within it. In general, multidimensional arrays allow you to store multiple arrays in a single variable.

A multidimensional array is an array containing one or more arrays. PHP supports multidimensional arrays that are two, three, four, five, or more levels deep. However, arrays more than three levels deep are hard to manage for most people.

Example:

<?php
$emp = array(  
    array(1,"Kailash",400000),  
    array(2,"Ranjeet",500000),  
    array(3,"Hemant",300000)  
  );  
  
  for ($row = 0; $row < 3; $row++) 
  {  
      for ($col = 0; $col < 3; $col++) 
      {  
          echo $emp[$row][$col]."  ";  
      }  
      echo "<br/>";  
  }  
?>

 

Output:

1 Kailash 400000
2 Ranjeet 500000
3 Hemant 300000