我有一个包含四级数据的多维数组。这是一个小样本:
$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
]
]
];
我需要Date
从数组的第三级收集所有值。
我知道如何遍历顶层,但我不知道如何编写其余代码以获取更深层次的Date
元素。
for($i = 0; $i < count($data); $i++) {
echo $i;
echo "<br>";
}
期望的输出:
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',
)