【发布时间】:2019-03-07 21:29:14
【问题描述】:
如果我没有使用正确的术语,我很抱歉,我还在学习。我试图弄清楚如何在其中包含嵌套数组的 JSON 数组中搜索特定值,然后返回关联值。
我的问题类似于 StackOverflow (How to search through a JSON Array in PHP) 上已回答的问题,但我希望能够在 people 或 中找到 item by id strong>dog 或任何其他嵌套数组。本质上,我想将 foreach 下面的people 转换为通配符。
这是我的 JSON 数据 - http://foothillertech.com/student/webdesign/2018/2018benrud2/tinker/dataIntro2/test/data.json
foreach($json->people as $item)
{
if($item->id == "8097")
{
echo $item->content;
}
}
非常感谢任何帮助。
【问题讨论】: