<?php
//echo $character->is_day . '<br>';
$url = '{"location":{"name":"London","region":"City of London, Greater London","country":"United Kingdom","lat":51.52,"lon":-0.11,"tz_id":"Europe/London","localtime_epoch":1672618641,"localtime":"2023-01-02 0:17"},"current":{"last_updated_epoch":1672618500,"last_updated":"2023-01-02 00:15","temp_c":8.0,"temp_f":46.4,"is_day":0,"condition":{"text":"Light rain","icon":"//cdn.weatherapi.com/weather/64x64/night/296.png","code":1183},"wind_mph":4.3,"wind_kph":6.8,"wind_degree":220,"wind_dir":"SW","pressure_mb":1009.0,"pressure_in":29.8,"precip_mm":0.0,"precip_in":0.0,"humidity":93,"cloud":25,"feelslike_c":7.0,"feelslike_f":44.7,"vis_km":10.0,"vis_miles":6.0,"uv":1.0,"gust_mph":5.8,"gust_kph":9.4}}';
$data = file_get_contents($url); // put the contents of the file into a variable
$characters = json_decode($data); // decode the JSON feed
foreach ($characters as $character) {
//location
$name = $character->name;
$region = $character->region;
$country = $character->country;
$lat = $character->lat;
$lon = $character->lon;
$tz_id = $character->tz_id;
$localtime_epoch = $character->localtime_epoch;
$localtime = $character->localtime;
echo$name;
}
?>
Here is the full code.
Thanks