How to terminate or break a loop in PHP?

By using break keyword in the loop, we can terminate or break a loop anywhere in PHP .

Example to break a PHP loop:

$months = array('jan', 'feb', 'mar', 'apr', 'stop', 'may');
foreach ($months as $month) {
    if ($month == 'stop') {
    echo "$month<br />";

Learn more about the similar topics:
No Content Found.
Exercises & Assignments
No Content Found.
Interview Questions & Answers
No Content Found.