]> Stephen's Gitweb - reasonableweather.git/commitdiff
Display icons for weather conditions
authorStephen Jianu <stephen@stephenjianu.com>
Tue, 18 Mar 2025 02:09:31 +0000 (21:09 -0500)
committerStephen Jianu <stephen@stephenjianu.com>
Tue, 18 Mar 2025 02:09:31 +0000 (21:09 -0500)
index.php

index f9ee33dbdf1220be0f2623964ae07ab565e52826..79f45d72643aa293ab697901dc1a2632cc4ba88f 100644 (file)
--- a/index.php
+++ b/index.php
@@ -12,7 +12,8 @@
                                $code = $json["current"]["weather_code"];
                                $isDay = ($json["current"]["is_day"]) ? "day" : "night";
                                $description = $jsonDescriptions[$code][$isDay]["description"];
-                               echo $description."<br>"."0&deg;";
+                               $image = $jsonDescriptions[$code][$isDay]["image"];
+                               echo "<img src=\"".$image."\"/><br>".$description."<br>"."0&deg;";
                        ?>
                </h1>
                <h3>Your 7 day forecast for Park Ridge is:</h3>
                        for ($i = 0; $i < 7; $i++) {
                                $code = $json["daily"]["weather_code"][$i];
                                $description = $jsonDescriptions[$code]["day"]["description"];
+                               $image = $jsonDescriptions[$code]["day"]["image"];
                                $tempHigh = $json["daily"]["temperature_2m_max"][$i];
                                $tempHighConverted = $tempHigh - $tempNow;
                                $tempLow = $json["daily"]["temperature_2m_min"][$i];
                                $tempLowConverted = $tempLow - $tempNow;
                                echo "<div style=\"min-width: 10%; display: inline-block;\">";
                                echo "<h3>";
-                               echo "".date('l', strtotime($json["daily"]["time"][$i]));
+                               echo "".date('l', strtotime($json["daily"]["time"][$i]))."<br><img src=\"".$image."\"/>";
                                echo "</h3>";
                                echo "<span style=\"font-weight: bold;\">".$description."</span><br>";
                                echo "<span style=\"font-weight: bold;\">High: </span>".$tempHighConverted."&deg;";