0

I have a script to extract the time, and for a long time I've been trying to round the degrees from 6.27C ° to 6C °. How can I do this?

<?php
$apiKey = "";
$cityId = "";
$apiUrl = "http://api.openweathermap.org/data/2.5/weather?id=" . $cityId . "&lang=en&units=metric&APPID=" . $apiKey;

$ch = curl_init();

curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $apiUrl);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);

curl_close($ch);
$data = json_decode($response);
$currentTime = time();

?>    


<span class="weather-temp"><?php echo $data->main->temp;?> C&deg;</span>
halfer
  • 19,824
  • 17
  • 99
  • 186
dzver
  • 1
  • 1
  • Your `$cityId` and `$apiKey` are empty in this code. Have they just been removed because you (understandable) don't want to share your API key? If so, you can leave the city ID in. – halfer May 08 '22 at 11:11
  • Are you getting a valid JSON result from the API call? – halfer May 08 '22 at 11:12
  • I receive all the data correctly, I have checked them several times. City ID is 733468. I just want the degrees to be rounded, not decimal. – dzver May 08 '22 at 15:57

0 Answers0