PHP Continue Statement

What is Continue Statement?

Explanation

"Continue" is used to skip the current loop iteration and continue with the next iteration of the loop. But "Break" is used to exit from the the whole loop.

Syntax:


Continue (Optional numeric argument);

In "Optional numeric argument" we can provide how many enclosing loops to skip.

Example :


<?php
for ($c = 0; $c <=10; ++$c) {
if ($c == 5)
{ continue;}
print "$c n";
}
?>

Result:


0 1 2 3 4 6 7 8 9 10

In the above example the iteration of the loop is skipped only when the value is 5, then all other number's are printed using the "print" statement.

PHP Topics


Ask Questions

Ask Question