Javatpoint Logo
Javatpoint Logo

PHP continue statement

The PHP continue statement is used to continue the loop. It continues the current flow of the program and skips the remaining code at the specified condition.

The continue statement is used within looping and switch control structure when you immediately jump to the next iteration.

The continue statement can be used with all types of loops such as - for, while, do-while, and foreach loop. The continue statement allows the user to skip the execution of the code for the specified condition.

Syntax

The syntax for the continue statement is given below:

Flowchart:

PHP continue statement

PHP Continue Example with for loop

Example

In the following example, we will print only those values of i and j that are same and skip others.

Output:

11
22 
33

PHP continue Example in while loop

Example

In the following example, we will print the even numbers between 1 to 20.

Output:

Even numbers between 1 to 20: 
2
4
6
8
10
12
14
16
18
20

PHP continue Example with array of string

Example

The following example prints the value of array elements except those for which the specified condition is true and continue statement is used.

Output:

One 
Two 
Three
Four

PHP continue Example with optional argument

The continue statement accepts an optional numeric value, which is used accordingly. The numeric value describes how many nested structures it will exit.

Example

Look at the below example to understand it better:

Output:

12
13
21 
23
31
32

Next TopicPHP Functions




Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA