PHP Multidimensional Array - javatpoint
PHP Multidimensional Array
PHP multidimensional array is also known as array of arrays. It allows you to store tabular data in an array. PHP multidimensional array can be represented in the form of matrix which is represented by row * column.
Definition
- $emp = array
- (
- array(1,"sonoo",400000),
- array(2,"john",500000),
- array(3,"rahul",300000)
- );
PHP Multidimensional Array Example
Let's see a simple example of PHP multidimensional array to display following tabular data. In this example, we are displaying 3 rows and 3 columns.
IdNameSalary1sonoo4000002john5000003rahul300000
File: multiarray.php
- <?php
- $emp = array
- (
- array(1,"sonoo",400000),
- array(2,"john",500000),
- array(3,"rahul",300000)
- );
- for ($row = 0; $row < 3; $row++) {
- for ($col = 0; $col < 3; $col++) {
- echo $emp[$row][$col]." ";
- }
- echo "<br/>";
- }
- ?>
Output:
Debugging your code - Php Xdebug Phpstorm #Shorts
1 sonoo 4000002 john 5000003 rahul 300000