PHP Basic Tutorial
A multidimensional array in PHP is an array containing one or more arrays. Multidimensional arrays allow you to create complex data structures, such as matrices, tables, or any nested structure. PHP supports both indexed and associative arrays as sub-arrays in a multidimensional array.
Note
The dimension of an array indicates the number of indices required to access a specific element in that array.
Let's see a simple example of PHP multidimensional array to display following tabular data. In this example, we are displaying 3 rows and 2 columns.
Name |
Age |
---|---|
John |
30 |
Alice |
25 |
Bob |
35 |
To get access to the elements of the above table we must point to the two indices (row and column):
Try it yourself