Currently trying to build a very basic weatherdata display, receiving data from openweathermap.org.
Using a curl session to get the data, afterwards I am decoding with json_decode and want to display the data inside a basic table.
I would like to implement the equivalent units in a third column (degrees, degrees celsius, hPa, %, km/h, ...) with if statements (if temp -> °C). Unfortunatly I dont know how to do this, thank you for your help.
My code:
$weatherData = json_decode($response, true);
echo "<table><tr><th>Category</th><th>Data</th><th>Units</th></tr>";
foreach($weatherData as $key => $value) {
foreach($value as $weatherKey => $weatherValue) {
echo "<tr><td>{$weatherKey}</td><td>{$weatherValue}</td><td>X</td></tr>";
}
}
echo "</table>";
Aucun commentaire:
Enregistrer un commentaire