I am looping through an array using foreach.
In a particular situation I need to know the value of the next element before iteration comes to that(like a prediction) element. For that I am planning to use the function next().
In documentation I just noticed that next() advances the internal array pointer forward.
next() behaves like current(), with one difference. It advances the internal array pointer one place forward before returning the element value. That means it returns the next array value and advances the internal array pointer by one.
If so will it affect my foreach loop?
It will not affect your loop if you use it in this way
OUTPUT
Try this code: