skip current iteration
You are looking for the continue statement. Also useful is break which will exit the loop completely. Both statements work with all variations of loop, ie. for
, foreach
and while
.
$numbers = array( 1, 2, 3, 4, 5, 6, 7, 8, 9 );foreach( $numbers as $number ) { if ( $number == 4 ) { continue; } // ... snip}