Let's say, I have an array like this:
$array = [
'car' => [
'BMW' => 'blue',
'toyota' => 'gray'
],
'animal' => [
'cat' => 'orange',
'horse' => 'white'
]
];
Then, I want to get all the values (the colour, 'blue'
, 'gray'
, 'orange'
, 'white'
) and join them into a single array. How do I do that without using foreach
twice?
Thanks in advance.
for-each
twice, then just call that function. – Ftlb