How do I get the result in the image? Here is my code for a weather forecast in php: Here is my code: Forecast Weather using PHP $data['list'][0]['weather'][0]['description'], 'icon' => $data['list'][0]['weather'][0]['icon'], 'maxtemp' => $data['list'][0]['temp']['max'], 'mintemp' => $data['list'][0]['temp']['min'], 'humidity' => $data['list'][0]['humidity'], 'speed' => $data['list'][0]['speed'] ); return $weather; } if (isset($_POST['city'])) { $city = $_POST['city']; $forecast = getForecast($city); if ($forecast) { echo ' ' . $city . ' Weather Forecast ' . date("l g:i a", $currentTime) . ' ' . date("jS F, Y", $currentTime) . ' ' . ucwords($forecast['description']) . ' High ' . $forecast['maxtemp'] . '°C Low ' . $forecast['mintemp'] . '°C Humidity: ' . $forecast['humidity'] . ' % Wind: ' . $forecast['speed'] . ' km/h '; } } else { echo ' City: '; } ?>
How do I get the result in the image?
Here is my code for a weather forecast in php:
Here is my code:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Forecast Weather using PHP</title>
<style>
.report-container {
border: #E0E0E0 1px solid;
padding: 20px 40px 40px 40px;
border-radius: 2px;
margin: 0 auto;
color: #929292;
}
.weather-icon {
vertical-align: middle;
margin-right: 20px;
}
.weather-forecast {
color: #212121;
font-size: 1.2em;
font-weight: bold;
margin: 20px 0px;
}
span.min-temperature {
margin-left: 15px;
color: #929292;
}
.time {
line-height: 25px;
}
</style>
</head>
<body>
<div class="report-container">
<?php
function getForecast($city) {
$country = "US";
$url = "http://api.openweathermap.org/data/2.5/forecast/daily?q=" . $city . "," . $country . "&units=metric&cnt=1&lang=en&appid=c0c4a4b4047b97ebc5948ac9c48c0559";
$json = file_get_contents($url);
$data = json_decode($json, true);
$weather = array(
'description' => $data['list'][0]['weather'][0]['description'],
'icon' => $data['list'][0]['weather'][0]['icon'],
'maxtemp' => $data['list'][0]['temp']['max'],
'mintemp' => $data['list'][0]['temp']['min'],
'humidity' => $data['list'][0]['humidity'],
'speed' => $data['list'][0]['speed']
);
return $weather;
}
if (isset($_POST['city'])) {
$city = $_POST['city'];
$forecast = getForecast($city);
if ($forecast) {
echo '
<h2>' . $city . ' Weather Forecast</h2>
<div class="time">
<div>' . date("l g:i a", $currentTime) . '</div>
<div>' . date("jS F, Y", $currentTime) . '</div>
<div>' . ucwords($forecast['description']) . '</div>
</div>
<div class="weather-forecast">
<img src="https://openweathermap.org/img/w/' . $forecast['icon'] . '.png" class="weather-icon" />
High ' . $forecast['maxtemp'] . '°C <span class="min-temperature">
Low ' . $forecast['mintemp'] . '°C</span>
</div>
<div class="time">
<div>Humidity: ' . $forecast['humidity'] . ' %</div>
<div>Wind: ' . $forecast['speed'] . ' km/h</div>
</div>';
}
} else {
echo '
<form method="POST" action="weatherforecast.php">
City: <input type="text" name="city"/><br/><br/>
<input type="submit" name="forecast" value="Get Forecast"/>
</form>
';
}
?>
</div>
</body>
</html>
![Weather Forecast (AssicX Forecast Weather using PHIX Forecast Weather using PH X ▸ (558) Weather app API X
C
Getting Started How To Java help Layout Design Theory ... Illustrator Special Effe...
Kansas City Weather
Wednesday 5:39 pm
19th April, 2023
Overcast Clouds
High 25.43°C Low 16.77°C
Humidity: 76 %
Wind: 10.12 km/h
Type here to search
cweb.northcentralus.cloudapp.azure.com/~philip/assignment5/weatherforecast.php
1
İ
C Create a function callecx
Reading Assignment: ...
CBS All Access Confir...
69°F
FavTutor - Live Coding X
www.myworkday.com
ចង
+
<
Best ASMR Microphon...
(4)
D
ENG
I
↓
5:44 PM
4/19/2023
X
»
4](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fa8a98030-23b4-434c-9935-d4f506016004%2F09cd52ef-c816-4222-8d34-034438b2efb7%2F558fo3t_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 7 steps with 5 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)