Learn PHP Programming

A backend server scripting language, and a powerful tool for making dynamic and interactive Web pages. Learn each topic with examples and output.

PHP Introduction
Control Structures
Php Forms
Php Advanced

PHP Continue Statement

In PHP, the continue statement is used within loops (such as for, foreach, while, and do...while loops) to skip the current iteration and move to the next one. The continue statement allows you to control the flow of a loop by skipping specific iterations when a certain condition is met. Here's how the continue statement is typically used:

Using continue in a while loop:

    $counter = 1;
    while ($counter <= 10) {
        $counter++;
        if ($counter % 3 == 0) {
            continue; // Skip numbers divisible by 3
        }
        echo $counter . " ";
    }
    
2 4 5 7 8 10

Next chapter is Switch Statement


Share this page on :

=