happy cat image

everdevel

coding

login
NotificationX
  • Currently, only notices of comments are displayed.
  • no comment or please login

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.

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

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?

<?php
    $i = 0;
    $max = 10;

    while($i < $max){
        $i++;
        if($i == 6) continue;
        echo $i.'<br>';
    }
?>

Result


Thank you for visiting. If you have any inquiry or explanation of mistakes, please use the comments below.


    
    

Back to the course

ALL COMMENTS 0

Sort by