I have a multidimensional array with four levels of data. Here's a small sample:
$data = [
[
[
'Date' => '2021-03-15T00:00:00.0000000+01:00',
'Arena' => ['Id' => 181796, 'Name' => 'Motala bibliotek'],
'Description' => null,
'IsCanceled' => null
],
[
'Date' => '2021-03-16T00:00:00.0000000+01:00',
'Arena' => ['Id' => 181796, 'Name' => 'Motala bibliotek'],
'Description' => null,
'IsCanceled' => null
],
[
'Date' => '2021-03-17T00:00:00.0000000+01:00',
'Arena' => ['Id' => 181796, 'Name' => 'Motala bibliotek'],
'Description' => null,
'IsCanceled' => null
]
],
[
[
'Date' => '2021-03-15T00:00:00.0000000+01:00',
'Arena' => ['Id' => 181796, 'Name' => 'Motala bibliotek'],
'Description' => null,
'IsCanceled' => null
],
[
'Date' => '2021-03-16T00:00:00.0000000+01:00',
'Arena' => ['Id' => 181796, 'Name' => 'Motala bibliotek'],
'Description' => null,
'IsCanceled' => null
]
]
];
I need to collect all of the Date
values from the third level in the array.
I know how to loop through the top level, but I am at a loss for how to write the rest of the code to get the deeper Date
elements.
for($i = 0; $i < count($data); $i++) {
echo $i;
echo "<br>";
}
Desired output:
array (
0 => '2021-03-15T00:00:00.0000000+01:00',
1 => '2021-03-16T00:00:00.0000000+01:00',
2 => '2021-03-17T00:00:00.0000000+01:00',
3 => '2021-03-15T00:00:00.0000000+01:00',
4 => '2021-03-16T00:00:00.0000000+01:00',
)