PHP Basic Tutorial
The break
statement is particularly useful when you need to stop loop execution based on a condition, preventing unnecessary iterations.
break
in a for
LoopThe break
statement can be used to jump out of a for
loop.
Try it yourself
break
in a while
LoopThe break
statement can be used to jump out of a while
loop.
Try it yourself
break
in a do...while
LoopThe break
statement can be used to jump out of a do...while
loop.
Try it yourself
break
in a foreach
LoopThe break
statement can be used to jump out of a foreach
loop.
Try it yourself