PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php $key = "523df554f4e883874873853b897b6da0"; $lat = "43.8029100"; $lon = "131.9457800"; $url = "https://api.openweathermap.org/data/2.5/forecast?lat=$lat&lon=$lon&appid=$key&units=metric"; $data = file_get_contents($url); $json = json_decode($data, true); foreach($json["list"] as $v){ // выводим температуру $temp[] = $v["main"]["temp"]; print_r("temp - ".$temp."\n"); // выводим дату $date = $v["dt"]; $date = date("d.m.Y H:i:s",$v["dt"]); // print_r("date - ".$date."\n"); } //выводим среднее арифметическое $d = count($temp); $s = array_sum($temp); print_r ("average - ".$s/$d); // $feel = $json["main"]["feels_like"]; // //$temp = $json["main"]["temp"]; // $vision = $json["visibility"]; // $wind = $json["wind"]; //$date = $json["dt"]; // $date = date("d.m.Y H:i:s"); //print_r($json);
Show:  
Copy Clear