function Fetch_Weather_Data($station_lat, $station_long) { global $date, $Next_Date; while (Strtotime($date) < strtotime($Next_Date)) { $URL = 'https://api.worldweatheronline.com/free/v2/weather.ashx?key=aa9967b205f647292c8eb466b7b8d&q=' . $station_lat . ',' . $station_long . '&num_of_days=5&tp=3&format=json&includeLocation=yes'; $jsonResult = file_get_contents($URL); $result = json_decode($jsonResult, true); $array = convertMultiDimJsonToAssoc($result['data']['current_condition'][0]); write_weather_data($array); sleep(60); $date = Date('d-m-Y'); echo $date; if (strtotime($date) == strtotime($Next_Date)) { $Next_Date = Date('d-m-Y', strtotime('+1 day')); } } }
function Fetch_Weather_Data($station_lat, $station_long) { $URL = 'https://api.worldweatheronline.com/free/v2/weather.ashx?key=aa9967b205f647292c8eb466b7b8d&q=' . $station_lat . ',' . $station_long . '&num_of_days=5&tp=3&format=json&includeLocation=yes&cc=no'; $jsonResult = file_get_contents($URL); $result = json_decode($jsonResult, true); //print_r($result); $TotalResult = count($result['data']['weather']); $TotalCount = 0; while ($TotalCount < $TotalResult) { $HourlyCount = 0; $Forecast_date = $result['data']['weather'][$TotalCount]['date']; write_weather_header($Forecast_date); $TotalHourlyCount = count($result['data']['weather'][$TotalCount]['hourly']); while ($HourlyCount < $TotalHourlyCount) { $array = convertMultiDimJsonToAssoc($result['data']['weather'][$TotalCount]['hourly'][$HourlyCount]); print_r($array); write_weather_data($array, $Forecast_date); $HourlyCount++; } $TotalCount++; } }