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}} {"dt":1459425600,"main":{"temp":-8.55,"temp_min":-10.55,"temp_max":-4.34}} {"dt":1459458000,"main":{"temp":-10.56,"temp_min":-15.55,"temp_max":-8.34}} ]} it is in the $ weatherDatas_json variable
Convert JSON data to an array variable
$weatherDatas = json_decode($weatherDatas_json, true); To output dt data from a 1 ( zero ) array element, do the following:
$weatherDt = $weatherDatas['city']['list'][0][dt]; echo $weatherDt; How to remove all dt from an array? Please tell me the while construct. I can not substitute the element number of the array automatically, and the data dt (array elements) can be a different number
foreach ($array as $key => $value) { echo "Index: $key, value: $value"; }foreach ($array as $key => $value) { echo "Index: $key, value: $value"; }? Through while, you can, for example, like this:while ($value = array_pop($array)) { echo $value; }while ($value = array_pop($array)) { echo $value; }There are a lot of ways, depending on the task, some may not work, but everything should work for output - BOPOH