Multidimensional Array

|

It is an array that stores one or more arrays inside it.

You can access the values of inner arrays using keys or indices. After running the program, the output looks like a table.

It displays data in rows and columns.

It helps to handle the complex or structured data very easily.

Syntax:

$array_name = array(
    array(value1, value2, value3),
    array(value4, value5, value6)
);

Example:

$students = array(
    array("Riya", 85, "A"),
    array("Aman", 78, "B"),
    array("Karan", 92, "A+")
);

// You will get the output after running the loop.

for($i = 0; $i < count($students); $i++) {
    for($j = 0; $j < count($students[$i]); $j++) {
        echo $students[$i][$j] . " ";
    }
    echo "\n";
}

Output:

Riya 85 A  
Aman 78 B  
Karan 92 A+

ONLINE WEB TOOLS

WhatIsMyIpAddress
Shorterner