[英]PHP How to get data from multiple level array
I have this array from JSON file and I want to get data from [url] .我有来自 JSON 文件的这个数组,我想从[url]获取数据。 Array is saved as variable
$data
.数组保存为变量
$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
)
)
)
Result should be like:结果应该是这样的:
echo $data[0]->url; will show the link/value /th?id=...
Your $data
variable is not an array, it's an instance of stdClass
.您的
$data
变量不是数组,而是stdClass
的一个实例。 Therefore, you can retrieve it like this:因此,您可以像这样检索它:
$data->images[0]->url;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.