I unfortunately got some problems getting the exact information I want out of this json file.
Thats a part of the json file:
{
"weather":[
{
"id":600,
"main":"Snow",
"description":"light snow",
"icon":"13n"
}
],
"base":"stations",
"main":{
"temp":271.15,
"feels_like":266.48,
"temp_min":271.15,
"temp_max":271.15,
"pressure":1020,
"humidity":86
}
}
Thats my code to read the informations:
$weather = file_get_contents("weather.json");
$weather = json_decode($weather);
foreach($weather->main as $main) { //<-- This dosen't works
echo $main->temp;
}
foreach($weather->weather as $w) { //<-- This works
echo $w->description;
}
I see that there is a different between the weather- and the main-part with the "[...]" but I don't know how to handle that. Thank you for everyone who helps! :)