提问人:MisterS 提问时间:11/12/2022 更新时间:11/12/2022 访问量:28
从嵌套的 json 数组 [duplicate] 中获取特定值
Get specific values from nested json array [duplicate]
问:
经过多次尝试和研究,我无法弄清楚,我希望有人可以帮助我。我可能看得太远了,但我没有以任何方式获得我需要的输出。
以下 json 输出来自 API:
Array
(
[group] => Array
(
[name] => Iedereen
[desc] => Iedereen
[type] => G
[instituteNumber] => Array
(
)
[children] => Array
(
[group] => Array
(
[0] => Array
(
[name] => Beheerders
[desc] => Beheerders
[type] => G
[code] => Beheerders
[instituteNumber] => Array
(
)
)
[1] => Array
(
[name] => Personeel
[desc] => Personeel
[type] => G
[code] => Personeel
[instituteNumber] => Array
(
)
[children] => Array
(
[group] => Array
(
[0] => Array
(
[name] => DT
[desc] => directieteam
[type] => G
[code] => DT5
[instituteNumber] => Array
(
)
)
由此,我想使用以下数据: (“personeel”下的所有数组)
[name] => DT
[type] => G
有人可以帮我吗?
答:
0赞
MisterS
11/12/2022
#1
发现它:)
foreach ($iedereen as $alles) {
foreach ($alles['children']['group'] as $hoofdgroepen) {
if($hoofdgroepen['name'] == "Personeel"){
foreach($hoofdgroepen['children']['group'] as $subgroepen) {
echo $subgroepen['name']."<br />";
}
}
}
}
评论