<?php
$weatherdata = file_get_contents('http://api.openweathermap.org/data/2.5/weather?id=appkey');
file_put_contents('weatherdata.json', $weatherdata);
$decoded = json_decode($weatherdata);
file_put_contents('weatherdata_alert.txt', $decoded->weather[0]->description);
?>
I can get the description from json data into a text entitled "weatherdata_alert.txt" but cannot seem to include other data from the string.. This is the desired result "clear sky 2° Millbrook" description being "clear sky"
This is the json data
{
"coord": {
"lon": -78.45,
"lat": 44.15
},
"weather": [{
"id": 804,
"main": "Clouds",
"description": "overcast clouds",
"icon": "04n"
}],
"base": "stations",
"main": {
"temp": 272.97,
"feels_like": 269.29,
"temp_min": 272.04,
"temp_max": 274.15,
"pressure": 1021,
"humidity": 69
},
"visibility": 10000,
"wind": {
"speed": 1.5,
"deg": 130
},
"clouds": {
"all": 90
},
"dt": 1604459237,
"sys": {
"type": 1,
"id": 882,
"country": "CA",
"sunrise": 1604404430,
"sunset": 1604440849
},
"timezone": -18000,
"id": 7804010,
"name": "Millbrook",
"cod": 200
}