PHP Break

The break statement can be used to jump out of different kind of loops.

Break in For loop

The break statement can be used to jump out of a for loop.

Example

Jump out of the loop when $x is 4:

for ($x = 0; $x < 10; $x++) {
  if ($x == 4) {
    break;
  }
  echo "The number is: $x <br>";
}

Continue reading PHP Break