Why does querying this JSON in this way not work?
$weather_data
{
"coord":{
"lon":-0.13,
"lat":51.51
},
"sys":{
"message":1.7255,
"country":"GB",
"sunrise":1430282118,
"sunset":1430335221
},
"weather":[
{
"id":800,
"main":"Clear",
"description":"Sky is Clear",
"icon":"01n"
}
],
"base":"stations",
"main":{
"temp":280.154,
"temp_min":280.154,
"temp_max":280.154,
"pressure":1018.05,
"sea_level":1026.07,
"grnd_level":1018.05,
"humidity":63
},
"wind":{
"speed":3.3,
"deg":253.501
},
"clouds":{
"all":0
},
"dt":1430337359,
"id":2643743,
"name":"London",
"cod":200
}
query.php
$json = json_decode($weather_data, TRUE);
$user_temp = $json['weather'][1]['main'];
My desired result is to get a value of "Clear" from inside that JSON. Troublesome.
I'm new to this, I've done some searching around and I couldn't discover a solution, thanks in advance for the help!