PHP break statement


The break is a keyword that are used as a jump statement which can be used in switch and looping statement.
Note:-if break appears in the inner loop of a nested loop control only comes out of the inner loop as.
Syntax:-
       for(……..)
     {
        ………
       if(condition)
      break
       ………
     }
the break statement causes the inner loop to be terminated the outer loop is still active.

Program for break statement.

 <html>
 <body>
 <?php
  for($i=1; $i<=10; $i++)
  if($i==5)
  {
  break;
  }
  echo $i;
  }
  ?>
 </body>
 </html>

Output

1
2
3
4