PHP - Statement break Statement


You can exit a loop at any point within loop by using the break statement.

It exits the loop and moves to the first line of code outside the loop.

The following while loop counts to 10 and then exits the loop:



         $count = 0;//from w w w  .  j av  a2 s  .c om

         while ( true ) {
           echo "I've counted to: $count \n ";
           if ( $count == 10 ) break;


Related Topics