I try to use api.openweathermap.org for get current weather. I use a php request to get a data. I sucessfully receive data and convert it to array with objects. I have a small question: How to get a value of key named "MAIN", which is equal to "Snow"? I try to use api.openweathermap.org for get current weather. I use a php request to get a data. I sucessfully receive data and convert it to array with objects. I have a small question: How to get a value of key named "MAIN", which is equal to "Snow"?
object(stdClass)#3 (14) {
["coord"]=>
object(stdClass)#1 (2) {
["lon"]=>
float(30.2642)
["lat"]=>
float(59.8944)
}
["weather"]=>
array(1) {
[0]=>
object(stdClass)#4 (4) {
["id"]=>
int(600)
["main"]=>
string(4) "Snow"
["description"]=>
string(27) "small snow"
["icon"]=>
string(3) "13n"
}
}
["base"]=>
string(8) "stations"
["main"]=>
object(stdClass)#5 (6) {
["temp"]=>
float(-11.94)
["feels_like"]=>
float(-18.94)
["temp_min"]=>
float(-15.2)
["temp_max"]=>
float(-11.08)
["pressure"]=>
int(1010)
["humidity"]=>
int(86)
}
["visibility"]=>
int(10000)
["wind"]=>
object(stdClass)#6 (2) {
["speed"]=>
int(4)
["deg"]=>
int(100)
}
["snow"]=>
object(stdClass)#7 (1) {
["1h"]=>
float(0.5)
}
["clouds"]=>
object(stdClass)#8 (1) {
["all"]=>
int(100)
}
["dt"]=>
int(1641652836)
["sys"]=>
object(stdClass)#9 (5) {
["type"]=>
int(2)
["id"]=>
int(197864)
["country"]=>
string(2) "RU"
["sunrise"]=>
int(1641624902)
["sunset"]=>
int(1641647737)
}
["timezone"]=>
int(10800)
["id"]=>
int(498817)
["name"]=>
string(29) "SPb"
["cod"]=>
int(200)
}
source https://stackoverflow.com/questions/70633590/how-to-get-value-from-array-with-objects
Comments
Post a Comment