Types of array: - In real world we have two types of array. These are following :-
Single dimensional array: -
In this array data items stored in only in one dimension.
Like $word  =”hello” which means the array $word stores the items in one dimension such as $word  $word  $word  $word  etc. The arrays which we have discussed in previous topics all are single dimensional array.
Multidimensional Arrays: -
If an array is able to store the items at more than one dimensional is called multidimensional array. Multidimensional array comes in picture where we need to store different association with single variable. For example if we want to make a matrix of size 2x2 the array representation will be.
$mat[ 0] =2
$mat[ 0] =4
$mat[ 1] =7
$mat[ 1] =6
Here the array $mat use two direction first is for row and second for column. So this is called two dimensional array. We can create any dimensional array in PHP . Such that
$threeDarray[ ][ ][ ]
$fourDarray[ ][ ][ ][ ]
$fifthDarray[ ][ ][ ][ ][ ]
$nDarray [ ][ ][ ][ ][ ][ ][ ]……..[ ][ ]
Concept of multidimensional array can be understood with the help of example:-
$shop= array(‘fruit’ =>
array(‘red’ => ‘apple’,
‘orange’ => ‘orange’,
‘yellow’ => ‘banana’,
‘green’ => ‘pear’),
array(‘red’ => ‘rose’,
‘yellow’ => ‘sunflower’,
‘purple’ => ‘iris’));
It is simply an array with two values stored in association with keys. Each of these values is
an array itself. After we have made the array, we can reference it like this:-
if we want to check which fruit of color red then we use
$shop [fruit][red]; this statement return the value “apple”.