Hi! Could we please enable some services and cookies to improve your experience and our website?
Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code
<?php
$key = "523df554f4e883874873853b897b6da0";
$lat = "46.675827";
$lon = "127.018433";
$url = "https://api.openweathermap.org/data/2.5/weather?lat=$lat&lon=$lon&appid=$key&units=metric";
$data = file_get_contents($url);
$json = json_decode($data, true);
$temp = $json["main"]["temp"];
$feel = $json["main"]["feels_like"];
$vision = $json["visibility"];
$vision2 = $vision/1000;
$wind = $json["wind"]["speed"];
$date = $json["dt"];
$date = date("d.m.y H:i");
echo("temperature °C: ".$temp."\n"."feels like: ".$feel."\n"."visibility: ".$vision2." km"."\n"."wind: ".$wind."m/s"."\n"."time: ".$date);