I have a multidimensional array coming from JSON. I cannot seem to get to print one value from all. It either gives me nothing or says array
. I need to print all the zip_code
fields.
$spit = json_decode($result);
Yields:
stdClass Object
(
[zip_codes] => Array
(
[0] => stdClass Object
(
[zip_code] => 33779
[distance] => 9.513
[city] => Largo
[state] => FL
)
[1] => stdClass Object
(
[zip_code] => 33771
[distance] => 9.188
[city] => Largo
[state] => FL
)
[2] => stdClass Object
(
[zip_code] => 33760
[distance] => 9.989
[city] => Clearwater
[state] => FL
)
[3] => stdClass Object
(
[zip_code] => 33770
[distance] => 8.525
[city] => Largo
[state] => FL
)
[4] => stdClass Object
(
[zip_code] => 33786
[distance] => 8.153
[city] => Belleair Beach
[state] => FL
)
[5] => stdClass Object
(
[zip_code] => 33764
[distance] => 7.651
[city] => Clearwater
[state] => FL
)
[6] => stdClass Object
(
[zip_code] => 33756
[distance] => 6.373
[city] => Clearwater
[state] => FL
)
I have tried to access with $zip=$spit->zip_codes->zip_code;
and $zip=['zip_codes']['zip_code'];
I am sure I am just missing the obvious but have tried about 20 ways to echo it out with no luck.