php - JSON对象循环
问题描述
如果存在,如何获取 instagram_business_id (id)?启用获取它,未定义索引 instagram_business_id 错误
$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);
print_r($res[0]['instagram_business_account']);
推荐阅读
- reactjs - 更改 MuiCheckbox 材质 UI 中的刻度颜色
- php - 如何在codeigniter中设置默认值?
- spring - 如何绑定对象列表以在 Spring Boot 和 thymeleaf 中发送 post 请求
- angular - Angular 8 通用组件
- openssl - 如何为 OP-TEE 小型可信操作系统构建 OpenSSL?
- stormcrawler - 如何在 StormCrawler 中下载图像和文件?
- windows - Win10 Docker Build:Invoke-WebRequest:无法连接到远程服务器
- xml - Xsl-Fo 如何修复分组引起的多个模板调用?
- asp.net-core-mvc - 从 .net core 中的策略中间件中识别函数名称
- visual-studio-code - VSCode:--jsx 标志会干扰自动导入建议