samedi 28 mars 2020

How to read an json files input, when the identifier contains a number [duplicate]

Hey I develope a php site where I read data from a weather api. The rain property of the json file is called 3h, so my script always throws an error:

$WeatherDataAPI is my decoded json object.

$valuesToday[$i]["rain"] = (float)$WeatherDataAPI->list[$i]->rain->3h;

and also the snow property

$valuesToday[$i]["snow"] = (float)$WeatherDataAPI->list[$i]->snow->5h;

Now when I write it like this Visual studio says: unexpected T_LNUMBER, expected T_STRING or T_VARIABLE

What should I do?




Aucun commentaire:

Enregistrer un commentaire