我对编码很陌生。我在网上看了很多例子,但似乎找不到我要找的东西。https://data.calgary.ca/resource/k7p9-kppz.json返回的 JSON:[ { ":@computed_region_4a3i_ccfj": "1", ":@computed_region_4b54_tmc4": "8", ":@computed_region_kxmf_bzkv": "29", ":@computed_region_p8tp_5dkv": "5", "description": "Glenmore Trail / 14 Street SW (West)", "latitude": "50.9938095441965", "location": { "latitude": "50.9938095441965", "longitude": "-114.094978074903", "human_address": "{\"address\": \"\", \"city\": \"\", \"state\": \"\", \"zip\": \"\"}" }, "longitude": "-114.094978074903", "quadrant": "SW", "url": { "url": "http://trafficcam.calgary.ca/loc111.jpg" } }, { ":@computed_region_4a3i_ccfj": "2", ":@computed_region_4b54_tmc4": "7", ":@computed_region_kxmf_bzkv": "62", ":@computed_region_p8tp_5dkv": "7", "description": "Memorial Drive / 9 Street NW", "latitude": "51.0536259017801", "location": { "latitude": "51.0536259017801", "longitude": "-114.081180764729", "human_address": "{\"address\": \"\", \"city\": \"\", \"state\": \"\", \"zip\": \"\"}" }, "longitude": "-114.081180764729", "quadrant": "NW", "url": { "url": "http://trafficcam.calgary.ca/loc59.jpg" } },我正在尝试获取description和url。我在获取description时没有问题,但是当我尝试获取时url,它会引发错误。
1 回答
慕森王
TA贡献1777条经验 获得超3个赞
尝试使用json_decode();
与true
作为second
PARAM,如果添加true
作为第二PARAM那么你可以得到assosiative阵列[数组的数组]对象的数组其他
$jsonToarray = json_decode($jsonData,true);// it will return array of array with assosiative format
并获得 url
echo $jsonToarray['url']['url'];die;
可以
description
直接使用,因为它不是嵌套的而是url
嵌套的数组,所以它们之间是有区别的
- 1 回答
- 0 关注
- 134 浏览
添加回答
举报
0/150
提交
取消