How do you navigate a matrix in PHP?

A multidimensional array is an array under an array, like this:

$array = array
(
array("brand"=>" Nissan", "stock"=> 15, "sold"=> 12),
array("brand"=>" Volswagen", "stock"=> 17, "sold"=> 11),
array("brand"=>" Totota", "stock"=> 8, "sold"=> 6),
array("brand"=>" Peugeot", "stock"=> 18, "sold"=> 14)
);
This table contains four cars and has two indices: rows and columns. To access or browse all the elements, we need to specify both the row and column indices.

echo $voitures[0][0].": In stock: ".$voitures[0][1].", Sold: ".$voitures[0][2].". 
";
Nissan In Stock: 15 Sold: 12
The keyless foreach buckle:

foreach($array as $item) {
echo $item['brand']." < br>"; print the brand of all cars

// to find out what's in object
// var_dump($item);
}
Runtime:

Nissan
Volswagen
Totota
Peugeot
Using the foreach loop with key:

foreach($array as $i => $item) {
echo $array[$i]['mark']." In stock: ".$array[$i]['stock']." Sold: ".$array[$i]['sold']." \n";

// $array[$i] is equilent to $item
}

Execution:

Nissan In Stock: 15 Sold: 12
Volswagen In Stock: 17 Sold: 11
Totota In Stock: 8 Sold: 6
Peugeot In Stock: 18 Sold: 14

With for loop:

for($i=0; $i < count($array); $i++) {
echo $array[$i]['brand']." In stock: ".$array[$i]['stock']." Sold: ".$array[$i]['sold']." \n";
}