An EasierWay to Iterate
As you can see, using this set of functions requires quite a bit of work; to be fair, there are some situations where they offer the only reasonable way of iterating through an array, particularly if you need to skip back-and-forth between its elements.
If, however, all you need to do is iterate through the entire array fromstart to finish, PHP provides a handy shortcut in the formof the foreach() construct:
As you can see, using this set of functions requires quite a bit of work; to be fair, there are some situations where they offer the only reasonable way of iterating through an array, particularly if you need to skip back-and-forth between its elements.
If, however, all you need to do is iterate through the entire array fromstart to finish, PHP provides a handy shortcut in the formof the foreach() construct: