There is an array of JSON:
{"city":{"id":2013159,"name":"London", "list": [ {"dt":1459360800,"main":{"temp":-6.55,"temp_min":-6.55,"temp_max":-2.34},"weather":[{"id":800,"main":"Clear","description":"ясно"}], {"dt":1459425600,"main":{"temp":-8.55,"temp_min":-10.55,"temp_max":-4.34},"weather":[{"id":700,"main":"Cloud","description":"Облака"}], {"dt":1459458000,"main":{"temp":-10.56,"temp_min":-15.55,"temp_max":-8.34},"weather":[{"id":600,"main":"Clear","description":"ясно"}] ]}
it is in the variable $ weatherDatas_json Converted JSON data into an array variable
$weatherDatas = json_decode($weatherDatas_json, true);
To display the data, all dt do this:
foreach ($weatherDatas["list"] as $key => $value) { echo $value["dt"],"\n"; }
Please help me with the output syntax: I want to output dt data from the first list array, and I can’t get the data from the second array, for example, id , like this:
foreach ($weatherDatas["list"]["weather"] as $key => $value) { echo $value["dt"],$value["id"],"\n"; }
but this does not work, error: PHP Notice: Undefined index: weather