continue

Passes control to the next iteration of the loop code block in which it appears, bypassing any remaining statements within that iteration of the code block.

 

<?php

	for($myVar ; $myVar < 10 ; $myVar++) {

		if ($myVar == 7) continue ; //skips to the next iteration if TRUE

		echo "\$myVar is currently $myVar<br>" ;
	}
	echo "<br>" ;
	echo "When the if condition for \$myVar evaluated to 7," ;
	echo "the loop continued through the other iterations, bypassing 7" ;
?>

Displays:

$myVar is currently 0
$myVar is currently 1
$myVar is currently 2
$myVar is currently 3
$myVar is currently 4
$myVar is currently 5
$myVar is currently 6
$myVar is currently 8
$myVar is currently 9 

When the if condition for $myVar evaluated to 7,the loop continued through the other iterations, bypassing 7

Leave a Reply