Skip to content
Advertisement

php foreach loop don’t work when I want to traverse json file

My foreach loop dont work. It brings me only 1st item info when i use $arr in my foreach loop but when i change that to $value it gives me nothing 🙁

JavaScript

Here is one of my elements in json file. I want to print all names and iso_a2 codes

JavaScript

Advertisement

Answer

I didn’t read, that it is a list of your example object. So better follow the other answer :S

You have an JSON Object (it is not an array/list) and I wonder if that even works. You want to get the features of the path “/Features/” right? So you have to change it like the following:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement