Hello guys just need a little help here. Because I have a json data and I decode it. But I can't access it using the foreach loop. When I tried to print the array structure I got this:
Array
(
[0] => stdClass Object
(
[code] => AD
[country] => Andorra
)
[1] => stdClass Object
(
[code] => AE
[country] => United Arab Emirates
)
[2] => stdClass Object
(
[code] => AF
[country] => Afghanistan
)
[3] => stdClass Object
(
[code] => AG
[country] => Antigua and Barbuda
)
.
.
.
All I want is to access the code and country
I used this loop but it display the index name and the values:
foreach($decode_country as $p){
foreach($p as $key => $value){
echo $key."--".$value."<br />";
}
}
But it display:
code--AD
country--Andorra
code--AE
country--United Arab Emirates
code--AF
country--Afghanistan
code--AG
country--Antigua and Barbuda
code--AI
country--Anguilla
code--AL
country--Albania
code--AM
country--Armenia