QUIZGUM

Coding Class

Quizgum : continue statement

Skip loops - Continue

If the loop encounters a continue statement while it is running, it skips one step.
The following example shows how to skip the continue statement when the value of variable i is 6.

  1. <?php
  2. for($i = 0; $i <= 10; $i++){
  3. if($i == 6) continue;
  4. echo $i.'<br>';
  5. }
  6. ?>

Result

If you look at the result, you can see that 6 is not taken and goes on to the next turn.
Should we also do it in the while statement?

  1. <?php
  2. $i = 0;
  3. $max = 10;
  4.  
  5. while($i < $max){
  6. $i++;
  7. if($i == 6) continue;
  8. echo $i.'<br>';
  9. }
  10. ?>

Result