break statement in PHP

In PHP break statement is used for the termination of the loop or switch statement.

Syntax :
break;

Example :
<?php
$i = 0;
while( $i < 10)
{
      $i++;
      if( $i == 5 )
            break;
}
      echo ("Loop stopped at i = $i" );
?>

Output :
Loop stopped at i = 5

0 Comments