I have a multidimensional array
array:2 [▼
"lamborghini" => array:1 [▼
"cars" => array:5 [▼
0 => "1"
1 => "4"
2 => "2"
3 => "5"
4 => "7"
]
]
"ferrari" => array:1 [▼
"cars" => array:1 [▼
0 => "8"
]
]
]
I tried to achieve the possible output like this
Lamborghini
1 4 2 5 7
ferrari
8
I tried this method
foreach($cars as $car)
{
foreach($car as $product)
{
for($i=0; $i<count($product); $i++)
{
echo $product[$i];
}
}
}
And output that I achieved is this
142578
Can anyone help me achieving the possible output? It should also print the first array name. eg
lamborghini
1 4 2 5 7