Skip to content
Advertisement

Looping through JSON Data

There is probably a simple response to this, but I’ve scoured the net trying to find an answer.

Imagine the following JSON data ($json):

JavaScript

What I’d like to do is loop through the data contained within Mid3, so that I can display Bottom1, Bottom2, etc.. so I thought this would work:

JavaScript

Does anyone know where I’m going wrong?

Advertisement

Answer

Your foreach is looking for Mid3 elements and not there child nodes.

Use:

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