Skip to content
Justice Tech School

break and continue

break stops a loop and continue skips to the next round. A number targets outer loops.

Example
for ($i = 1; $i <= 5; $i++) {
    if ($i == 2) continue;
    if ($i == 4) break;
    echo $i, " ";
}

Result

1 3 

Exercise

Skip a round.

;

Quiz Test

What does break do?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.