PHP Multidimensional Array

PHP Multidimensional Array

PHP Multidimensional Array : A multidimensional array is an array containing one or more arrays.

PHP multidimensional arrays can be any level deep. However, arrays more than three levels deep are hard to manage .

In other words a multidimentional array is the collection of arrays . which can be manages with  indices to select an element.
2D array needs 2 indices to select an element,3D array you needs 3 indices to select an element, as the level increases the number of indices also increases.

For Example : If you want to store Employee information eg name , age , employee id than it can be stored in an array which is collection of array of employee detail.

 <?php 
$empinfo= array
(
array(\"A\",22,18),
array(\"B\",15,13),
array(\"C\",15,12),
array(\"D\",17,15)
);
?>

///To retrive data from array of B we use to

<?php  
echo $empinfo[1][0].\": name: \".$empinfo[1][1].\", sold: \".$empinfo[1][2].\".<br>\";

?> 
Scroll to Top