continue statement in PHP

In PHP continue statement skips some lines of code inside the loop and continues with the next iteration. It is mainly used for a condition so that we can skip some code for a particular condition.

Syntax:
continue;

Example :
<?php
for ($i=0; $i<=10; $i++)
{
      if($i==3) /* skip the iteration */
      {
            continue;
      }
      echo "The number is ".$i."<br>";
}
?>

Output :
The number is 0
The number is 1
The number is 2
The number is 4
The number is 5
The number is 6
The number is 7
The number is 8
The number is 9
The number is 10

0 Comments