Got an assignment for school to make a multidimensional array.
<?php
$cars = array(
"car1" => array (
"brand" => 'BMW',
"license" => '30-KL-PO',
"price" => 10000
),
"car2" => array (
"brand" => 'Mercedes',
"license" => '51-ZD-ZD',
"price" => 20000
),
"car3" => array (
"brand" => 'Maserati',
"license" => 'JB-47-02',
"price" => 30000
)
);
foreach($carss as $car){
echo $car['car1']['brand'] . $car['car1']['brand'] . "<br>";
}
?>
I need to show the brand and license of all the cars using a foreach. I tried it with only car1 and I got the error: Undefined index: car1.
I know how to get it to show using only echo but my assignment says that I have to using a foreach.