Continue
continue is used to control looping structure . continue will skip the rest of the statement in the current loop and continue the next iteration of the loop.
printing odd numbers
<?php
for($i=0;$i<20;$i++)
{
if($i%2==0) continue; // skip the rest of the loop if the number is even
echo $i;
}
?>
continue accepts an optional numeric argument which tells it how many levels of enclosing loops it should skip to the end of.
<?php
$i=0;
while($i<20)
{
while($i){
echo $i;
continue 2; //// this will continue the loop while($i<20)
echo ‘ iam not reachable’;
}
echo ‘this cannot be reached’;
}
?>
