有人能帮我在php的foreach循环中使用json数据吗?

有人能帮我在php的foreach循环中使用json数据吗?,php,arrays,json,Php,Arrays,Json,我使用下面的php代码在我的文件中使用json,但我没有得到输出。我需要从Json数组打印图像url。有人能帮忙吗 Json数据是: { "pagination": {}, "data": [ { "id": "1980025670135540608_1039191866", "user": {}, "images": { "thumbnail": { "width": 150, "hei

我使用下面的php代码在我的文件中使用json,但我没有得到输出。我需要从Json数组打印图像url。有人能帮忙吗

Json数据是:

{
  "pagination": {},
  "data": [
    {
      "id": "1980025670135540608_1039191866",
      "user": {},
      "images": {
        "thumbnail": {
          "width": 150,
          "height": 150,
          "url": "https://scontent.cdninstagram.com/vp/d3d00967ec82131dedfdddb0cb8f8bc7/5CFCE4F1/t51.2885-15/e35/s150x150/50959433_383283642451967_2367872435860221844_n.jpg?_nc_ht=scontent.cdninstagram.com"
        },
        "low_resolution": {
          "width": 320,
          "height": 320,
          "url": "https://scontent.cdninstagram.com/vp/5cb939b696c2d5a0211572bd0e965bee/5CF41C01/t51.2885-15/e35/s320x320/50959433_383283642451967_2367872435860221844_n.jpg?_nc_ht=scontent.cdninstagram.com"
        },
        "standard_resolution": {
          "width": 640,
          "height": 640,
          "url": "https://scontent.cdninstagram.com/vp/411df4ade429230dee0ab3631d25a6eb/5CE56DB3/t51.2885-15/e35/50959433_383283642451967_2367872435860221844_n.jpg?_nc_ht=scontent.cdninstagram.com"
        }
      },
      "created_time": "1550257475",
      "caption": null,
      "user_has_liked": false,
      "likes": {
        "count": 0
      },
      "tags": {},
      "filter": "Normal",
      "comments": {
        "count": 0
      },
      "type": "image",
      "link": "https://www.instagram.com/p/Bt6dts6lWuA/",
      "location": null,
      "attribution": null,
      "users_in_photo": {}
    },
    {
      "id": "1979798389190546391_1039191866",
      "user": {
        "id": "1039191866",
        "full_name": "Jagjeet Kumar",
        "profile_picture": "https://scontent.cdninstagram.com/vp/9871a297c832e1b1ef249028856af412/5CFC0D7D/t51.2885-19/11931260_1465802173750145_760962573_a.jpg?_nc_ht=scontent.cdninstagram.com",
        "username": "jagjeet_k"
      },
      "images": {
        "thumbnail": {
          "width": 150,
          "height": 150,
          "url": "https://scontent.cdninstagram.com/vp/5f7e27fbf6d878bb85be23b70b637866/5CF8244F/t51.2885-15/e35/s150x150/50801938_1432836230186365_4210258679421826307_n.jpg?_nc_ht=scontent.cdninstagram.com"
        },
        "low_resolution": {
          "width": 320,
          "height": 320,
          "url": "https://scontent.cdninstagram.com/vp/16376fe1eb033705d1c7b1f394bef013/5CE38537/t51.2885-15/e35/s320x320/50801938_1432836230186365_4210258679421826307_n.jpg?_nc_ht=scontent.cdninstagram.com"
        },
        "standard_resolution": {
          "width": 640,
          "height": 640,
          "url": "https://scontent.cdninstagram.com/vp/c51878930ed8c98a595f16299f5c18d7/5CF9E7CA/t51.2885-15/sh0.08/e35/s640x640/50801938_1432836230186365_4210258679421826307_n.jpg?_nc_ht=scontent.cdninstagram.com"
        }
      },
      "created_time": "1550230381",
      "caption": null,
      "user_has_liked": false,
      "likes": {
        "count": 1
      },
      "tags": {},
      "filter": "Crema",
      "comments": {
        "count": 1
      },
      "type": "image",
      "link": "https://www.instagram.com/p/Bt5qCVCl9PX/",
      "location": null,
      "attribution": null,
      "users_in_photo": {}
    }
  ],
  "meta": {
    "code": 200
  }
}
我正在使用的Php代码:

<?php

    $instagram_feed_data = json_decode($mediacount, true);

    foreach ($instagram_feed_data->data as $item) { 

    $img_url = $item['images']['low_resolution']['url']; 

?> 

   <img src="<?= $img_url; ?>">

<?php

} 

">
将真值传递给
json\u decode()
的第二个参数会告诉PHP您想要返回一个数组而不是一个对象。因此,您不能像这样使用对象句柄解除对它的引用:

foreach ($instagram_feed_data->data as $item) { 
foreach ($instagram_feed_data['data'] as $item) {
您需要如下所示的数组引用:

foreach ($instagram_feed_data->data as $item) { 
foreach ($instagram_feed_data['data'] as $item) {

按指示设置$img_url后,如果回显该url,会发生什么情况?