Here parameters of API respond :
{"cod":"200","message":0.0045,
"city":{"id":1851632,"name":"Shuzenji",
"coord":{"lon":138.933334,"lat":34.966671},
"country":"JP"},
"cnt":38,
"list":[{
"dt":1406106000,
"main":{
"temp":298.77,
"temp_min":298.77,
"temp_max":298.774,
"pressure":1005.93,
"sea_level":1018.18,
"grnd_level":1005.93,
"humidity":87},
"weather":[{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04d"}],
"clouds":{"all":88},
"wind":{"speed":5.71,"deg":229.501},
"sys":{"pod":"d"},
"dt_txt":"2014-07-23 09:00:00"}
]}
I can't get value "Overcast" with my php code :
echo $data['list'][0]['weather']['description'];
echo $data['list'][1]['weather']['description'];
...
I tried several combinaison, i read this article How do I extract data from JSON with PHP?
But nothing work...
It looks like 'weather' is an array.
Try $data['list'][0]['weather'][0]['description'];
First, make sure you have decoded the json.
$decodedData = json_decode($data);
Then, try accessing the object's properties and arrays like this:
echo $decodedData->list[0]->weather[0]->description;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.