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;
}
}
?>