PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php $city[] = 'Macae'; $city[] = 'Tallinn'; $city[] = 'Oslo'; $city[] = 'Owerri'; foreach($city as $v){ echo getTemp($v)."\n"; } function getTemp($city){ $apiKey='523df554f4e883874873853b897b6da0'; $url="https://api.openweathermap.org/data/2.5/weather?q=$city&appid=$apiKey&units=metric"; $json=file_get_contents($url); $data=json_decode($json,true); return $data['main']['temp']; } ?>
Show:  
Copy Clear