Php JSON对象循环
如果有instagram\u business\u id(id),如何获取该id?启用获取,未定义索引instagram\u business\u id错误Php JSON对象循环,php,json,Php,Json,如果有instagram\u business\u id(id),如何获取该id?启用获取,未定义索引instagram\u business\u id错误 $pages = '[ { "access_token": "", "instagram_business_account": { "id": "123" }, "name": "Page Name", "id": "XXX" }, { "access_toke
$pages = '[
{
"access_token": "",
"instagram_business_account": {
"id": "123"
},
"name": "Page Name",
"id": "XXX"
},
{
"access_token": "",
"name": "Page Name2",
"id": "XXX"
}
]';
Loop
foreach($pages as $page){
}
检查下面的代码
$res=json_decode($pages,true)
打印($res[0]['instagram\u business\u account']) 尝试
$pages=json\u解码($pages)
在$pages=json\u decode($pages)
之后尝试此操作:foreach($key=>$obj页面){if(isset($obj->instagram\u business\u账户)){$instagram=$obj->instagram\u business\u账户;if(isset($instagram->id)){echo$instagram->id;}}
同一问题未定义索引:instagram\u business\u Account我使用了以下代码,请让我知道您的输出是否不同没有仅输出错误出现了什么错误??