-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
96 lines (69 loc) · 2.82 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
$url = "http://api.openweathermap.org/data/2.5/forecast?&id=1185241&lang=en&units=metric&APPID=a5691a6fdfebcdea5d860ecb4c3fbd86";
date_default_timezone_set("Asia/Dhaka");
$DateTime = strftime("%Y-%m-%d");
$contents = file_get_contents($url);
$clima=json_decode($contents);
$weather_list = $clima->list;
/*
$temp_max=$clima->main->temp_max;
$temp_min=$clima->main->temp_min;
$today = date("F j, Y, g:i a");
$cityname = $clima->name;
echo $cityname . " - " .$today . "<br>";
echo "Temp Max: " . $temp_max . "°C<br>";
echo "Temp Min: " . $temp_min . "°C<br>";*/
?>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Weather Forecast</title>
<!-- CSS only -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
<link href="css/styles.css" rel="stylesheet">
</head>
<body>
<h1 class="text-light text-center">Dhaka | BD | Weather Forecast for Five Days</h1>
<div class="container flex-lg-nowrap">
<section class="container py-2 mb-4 opacity">
<div class="row">
<!-- start here -->
<?php
foreach ($weather_list as $list) {
foreach ($list as $list_item) {
if (is_string($list_item)) {
if (strlen($list_item) == 19) {
$temp_min = $list->main->temp_min;
$temp_max = $list->main->temp_max;
?>
<div class="col-lg-4">
<div class="card bg-light text-light mb-3 " >
<div class="card-header text-black">
<h2>Date: <?php echo substr($list_item, 0, 10); ?></h2>
<h2>Time: <?php echo substr($list_item, 12, 19); ?></h2>
</div>
<div class="card-body bg-white text-dark">
<div>
<div class="container text-op">
<h4>Min Temp -> <?php echo $temp_min . "°C"; ?></h4>
<h4>Max Temp -> <?php echo $temp_max . "°C"; ?></h4>
</div>
</div>
</div>
</div>
</div>
<?php
}
}
}
}
?>
<!-- end here -->
</div>
</section>
</div>
</div>
</body>
</html>