PHP continue

In this chapter you will learn:

  1. What is a continue statement
  2. Example - using continue to start the next iteration

Description

continue causes PHP to skip the rest of the current loop iteration and go on to the next iteration.

Example

The following code uses the continue statement to start the next iteration.


<?php// j  a  v  a2 s  .com
        for ($i = 1; $i < 10; $i = $i + 1) {
                if ($i == 3) continue;
                if ($i == 7) break;
                print "Number $i\n";
        }
?>

The code above generates the following result.

Next chapter...

What you will learn in the next chapter:

  1. What is the PHP Mixed-Mode Processing
  2. Syntax for PHP Mixed-Mode
  3. Example - PHP mix code
Home » PHP Tutorial » PHP Statements
PHP Code Blocks
PHP Comments
PHP if
PHP if else
PHP switch
PHP foreach
PHP while loop
PHP do while loop
PHP for loop
PHP break
PHP continue
PHP Mixed-Mode Processing
PHP include/require