Advertisement
Guest User

Untitled

a guest
May 3rd, 2016
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. if(isset($city))
  2.  
  3. $curl = curl_init();
  4. $headers = array();
  5. curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
  6. curl_setopt($curl, CURLOPT_HEADER, 0);
  7. curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  8. curl_setopt($curl, CURLOPT_URL, $url);
  9. curl_setopt($curl, CURLOPT_TIMEOUT, 30);
  10. $json = curl_exec($curl);
  11. curl_close($curl);
  12.  
  13. $data = json_decode($json);
  14.  
  15. if(!empty($data->list[0]->name)) {
  16. ?>
  17. <div>
  18. Stadt: <strong><?php echo $data->list[0]->name ?></strong><br />
  19. Aktuell:<strong><?php echo number_format($data->list[0]->main->temp - 273.15, 1, ',', '') ?> &deg; C </strong><br />
  20. Temperatur (heute): <br />
  21. min. <?php echo number_format($data->list[0]->main->temp_min - 273.15, 1, ',', '') ?> &deg; C<br />
  22. max. <?php echo number_format($data->list[0]->main->temp_max - 273.15, 1, ',', '') ?> &deg; C<br />
  23. Luftfeuchtigkeit: <?php echo number_format($data->list[0]->main->humidity)?> %<br />
  24. Windgeschwindigkeit: <?php echo $data->list[0]->wind->speed ?>m/s<br />
  25. Windrichtung: <?php echo $data->list[0]->wind->deg ?>&deg;<br />
  26. Wolken: <?php echo $data->list[0]->clouds->all ?>%<br />
  27. Wetter: <?php echo $data->list[0]->weather->description ?><br />
  28. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement