JSON对象循环

时间:2018-08-07 08:21:35

标签: 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){

}

1 个答案:

答案 0 :(得分:0)

检查以下代码 $ res = json_decode($ pages,true);

print_r($ res [0] ['instagram_business_account']);