July 2018
Beginner
552 pages
13h 18m
English
You have now learned about the basics of the loops, but you might have asked yourself: is it possible to skip some loops or to just break the looping process? For this purpose, there are the keywords break and continue. The continue keyword will just skip the current statement and jump to the looping header or footer for the next loop. The break keyword will jump completely out of the looping process and start executing the code after the loop. Let's take a look at a simple example:
# simple example for break in a do-while loop$a = 0do { $a++ $a if ($a -gt 2) { break; }}while ($a -lt 5)# 1, 2, 3
As you can see, we have just added an additional if condition, which executes the break statement after the third execution ...
Read now
Unlock full access