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
$apiKey="523df554f4e883874873853b897b6da0";
$city="Onitsha";
$url="https://api.openweathermap.org/data/2.5/forecast?q=$city&appid=$apiKey";
$json=file_get_contents($url);
$data=json_decode($json,true);
$wind1=[];
$wind2=[];
$wind3=[];
foreach($data['list']as $v){
$wind1=[$v['dt']] = $v['wind']['speed'];
$wind2[]=[
'dt'=$v['dt'],
'speed'=>$v['wind']['speed']
];
}
rsort(wind1);
usort($wind2,function($a,$b){
return $b['speed']<=>$a['speed'];
});
echo"wind2 date: ".date('d.m.Y H:i',$wind2[0]['dt'])."speed:".$wind2[0]['speed'];