Javatpoint Logo
Javatpoint Logo

PHP Break

PHP break statement breaks the execution of current for, while, do-while, switch and for-each loop. If you use break inside inner loop, it breaks the execution of inner loop only.

Syntax

Flowchart

PHP break statement flowchart

PHP Break: inside loop

Let's see a simple example to break the execution of for loop if value of i is equal to 5.

Output:

1
2
3
4
5

PHP Break: inside inner loop

The PHP break statement breaks the execution of inner loop only.

Output:

1 1
1 2
1 3
2 1
2 2
3 1
3 2
3 3

PHP Break: inside switch statement

The PHP break statement breaks the flow of switch case also.

Output:

number is equal to 200
Next TopicPHP Functions




Help Others, Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA