1
1
<?php
2
- error_reporting (0 );
2
+ // error_reporting(0);
3
3
/*
4
4
* OpenWeatherMap-PHP-API — A PHP API to parse weather data from https://OpenWeatherMap.org.
5
5
*
@@ -47,7 +47,7 @@ function getWeathers(){
47
47
$ this ->mydata [$ key ]['temp ' ] = $ weather ->temperature ->getValue ();
48
48
$ this ->mydata [$ key ]['humidity ' ] = $ weather ->humidity ->getValue ();
49
49
$ this ->mydata [$ key ]['wind ' ] = $ weather ->wind ->speed ->getValue ();
50
- $ this ->mydata [$ key ]['scores ' ] = 0 ;
50
+ $ this ->mydata [$ key ]['score ' ] = 0 ;
51
51
$ this ->mydata [$ key ]['time ' ] = $ weather ->lastUpdate ->format ('Y-m-d H:i:s ' );
52
52
}
53
53
}
@@ -61,7 +61,7 @@ function checkTemp(){
61
61
});
62
62
63
63
foreach ($ this ->mydata as $ key => $ value ) {
64
- $ this ->mydata [$ key ]['scores ' ] += (100 - 10 * (($ key + 1 ) - 1 )) * 0.6 ;
64
+ $ this ->mydata [$ key ]['score ' ] += (100 - 10 * (($ key + 1 ) - 1 )) * 0.6 ;
65
65
}
66
66
}
67
67
@@ -74,7 +74,7 @@ function checkWind(){
74
74
});
75
75
76
76
foreach ($ this ->mydata as $ key => $ value ) {
77
- $ this ->mydata [$ key ]['scores ' ] += (100 - 10 * (($ key + 1 ) - 1 )) * 0.3 ;
77
+ $ this ->mydata [$ key ]['score ' ] += (100 - 10 * (($ key + 1 ) - 1 )) * 0.3 ;
78
78
}
79
79
}
80
80
@@ -87,13 +87,13 @@ function checkHumidity(){
87
87
});
88
88
89
89
foreach ($ this ->mydata as $ key => $ value ) {
90
- $ this ->mydata [$ key ]['scores ' ] += (100 - 10 * (($ key + 1 ) - 1 )) * 0.1 ;
90
+ $ this ->mydata [$ key ]['score ' ] += (100 - 10 * (($ key + 1 ) - 1 )) * 0.1 ;
91
91
}
92
92
}
93
93
94
94
function printScores (){
95
95
usort ($ this ->mydata , function ($ a ,$ b ){
96
- $ c = $ b ['scores ' ] - $ a ['scores ' ];
96
+ $ c = $ b ['score ' ] - $ a ['score ' ];
97
97
$ c .= $ b ['humidity ' ] - $ a ['humidity ' ];
98
98
$ c .= strcmp ($ a ['wind ' ],$ b ['wind ' ]);
99
99
return $ c ;
@@ -102,8 +102,6 @@ function printScores(){
102
102
header ('Content-Type: application/json ' );
103
103
echo json_encode ($ this ->mydata , JSON_FORCE_OBJECT );
104
104
}
105
-
106
-
107
105
}
108
106
109
107
$ weather = new MyWeather ($ myApiKey , $ _GET ['city ' ]);
0 commit comments