php - Why does JSON have extra square bracket in output? -
my json (decoded) has square brackets after subdivisions
part, can't target target other parts using, example, $resultarray['country']['geoname_id'];
. why there pair of square brackets there?
string(1461) "{"country":{"iso_code":"ca","names":{"pt-br":"canadá","es":"canadá","ru":"Канада","en":"canada","zh-cn":"加拿大","fr":"canada","de":"kanada","ja":"カナダ"},"confidence":99,"geoname_id":6251999},"location":{"longitude":-79.4886,"latitude":43.7496,"time_zone":"america/toronto","accuracy_radius":10},"subdivisions":[{"iso_code":"on","names":{"en":"ontario","zh-cn":"安大略","pt-br":"ontário","ja":"オンタリオ州","ru":"Онтарио"},"confidence":93,"geoname_id":6093943}],"postal":{"confidence":17,"code":"m3j"},.....
i'm referring to
"subdivisions":[{"iso_code":"on"
this part, , closing one. why subdivisions thing have square brackets?
subdivisions it's array, in json, these objects:
{key:value}
and these arrays:
[{key1:value1},{key2:value2}]
just javascript. in case, subdivisions can have multiple values, if decode in php json_decode() you'll array 1 object in.
Comments
Post a Comment