PHP: How to Skip to the Next Iteration of a Loop CodeUnit 22 MAR 2010

By now, you’ll know that loops are essential to your livelihood as a programmer and as such you have lovingly nurtured your loops, nesting and expanding them, and in general just making them better little iterations with each passing moment in your life as a developer.

But what happens when you want a loop to skip over a particular section? What if you want to jump forward a couple of iterations and hit that all important third loop?

Well have no fear, in direct contrast the PHP’s handy little break directive, PHP also comes packaged with the neat continue functionality that allows you to literally skip ahead within any sort of loop structure.

Using the continue functionality turns out to be a pretty simple thing to do – after all, anywhere within any type of loop, you simply put continue; which if read will force the script into the next loop iteration, handy if you don’t want to process some or other variable because of its state this time around.

You can read up more about it as well as the other PHP control structures here.

Related Link:

Related Posts:

About Craig Lotter

South African software architect and developer at Touchwork. Husband to a cupcake baker and father to two little girls. I don't have time for myself any more.