Continue

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’;
}

?>

Leave a Reply


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.