我有一个来自JSON文件的数组,我想从 [url] 获取数据。数组另存为变量$data
。
stdClass Object
(
[images] => Array
(
[0] => stdClass Object
(
[startdate] => 20190625
[fullstartdate] => 201906250700
[enddate] => 20190626
[url] => /th?id=OHR.SutherlandFalls_ROW5711472757_1920x1080.jpg&rf=LaDigue_1920x1080.jpg&pid=hp
)
)
)
结果应类似于:
echo $data[0]->url; will show the link/value /th?id=...
答案 0 :(得分:1)
您的$data
变量不是数组,而是stdClass
的实例。因此,您可以像这样检索它:
$data->images[0]->url;