PHP

The continue

continue is used within looping structures to skip the rest of the current loop iteration and continue execution at the condition evaluation and then the beginning of the next iteration.

Syntax:

continue;

Example:

Following example demonstrate of 1, 2, 3, 4, ram game we play in childhood. here we will check condition, if $i % 5 is 0 then it will print ram and skip loop. it means it will continue from beginning of loop.

<?php
for ($i = 1; $i <= 20; $i++) {
    if ($i % 5 == 0) {
        echo 'ram<br />';
        continue;
    }
        
    echo $i.'<br />';
}
?>

Output:

Tutorialik.com
1
2
3
4
ram
6
7
8
9
ram
11
12
13
14
ram
16
17
18
19
ram



Subscribe us on Youtube

Share This Page on


Ask Question