Skip to content
Advertisement

php for loop from array stops after 3 loops

I have an array that looks like this.

JavaScript

I want to loop through array in the first key of [2] and echo all the values.

JavaScript

this works, but stops after three loops and the output looks like this:

JavaScript

I am expecting — hoping for this:

JavaScript

I don’t understand why it is stopping. thanks.

Advertisement

Answer

Your problem lies here:

JavaScript

You are counting the elements of $nt (which are 3), but you want to access the elements of $nt[2] (which are 5). Thus, you need to change the above line to:

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