PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php $lat = "43.8029100"; $lon = "131.9457800"; $key = "523df554f4e883874873853b897b6da0"; $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); #print_r($json); foreach($json['list'] as $v){ $cb1[] = $v['main']['temp']; $cb3 = $v['main']['temp']; $cb0_1= $v['dt']; $cb0_1 = date("H:i y-m-d",$v['dt']); # echo("Temperature: ".$cb3." °C "."Date: ".$cb0_1.".\n" ); $cb4[] = $v['main']['temp_min']; $cb4 = $v['main']['temp_min']; $cb5[] = $v['main']['temp_max']; $cb5 = $v['main']['temp_max']; $cb0_1 = date("y-m-d",$v['dt']); $cb3_1[] = $cb0_1; }; $nw = array_diff($cb4, $cb5); echo $nw; $sum = array_sum($cb1); $cou = count($cb1); $cb2 = $sum / $cou; echo ("Average temperature: ".round($cb2, 0)."\n") ; echo ("First date: ".$cb3_1[0]."\n"); echo end($cb3_1);
Show:  
Copy Clear