PHP break Keyword

PHP callable Keyword
PHP case Keyword

In this article, you will learn how to break or stop the execution of the loop in PHP. The break keyword in PHP is used to break out of for loops, foreach loops, while loops, do..while loops and switch conditions.

examples of the BREAK keyword

Example 1. In this example, we break out of a loop.

<?php
$cars = ["Ford", "Volvo", "BMW"];
foreach($cars as $car) {
  echo $car;
  echo "<br>";
  if($car == "Volvo") {
    break;
  }
}
?>
PHP callable Keyword
PHP case Keyword

Stay up-to-date about PHP!

We don’t spam!

en English
X
Scroll to Top