Difference between break and continue in PHP

PHP

The difference between break and continue:
  • The breakstatement ends the entire iteration of the loop, while continueskips the current iteration.
  • The breakstatement ends the entire loop early, while continueleads to the next iteration earlier.
  • In the loop for a switch, breakacts as a terminator for a case, whereas continue 2acts as a terminator for a case and skips the current loop iteration.
  • Program 1:This program illustrates a continue statement inside a loop. for ( $i = 1; $i < 10; $i ++) { if ( $i % 2 == 0) { continue ; } echo $i . "" ; }
    ?>
    Output: Program 2:This program illustrates a break statement inside a loop. for ( $i = 1; $i < 10; $i ++) { if ( $i == 5) { break ; } echo $i . "" ; }
    ?>
    Output: Program 3:Using a radio button inside an outline and continuing 2 inside a radio button body. for ( $i = 10 ; $i < = 15; $i ++) { switch ( $i ) { case 10: echo " Ten " ; break ; case 11: continue 2; case 12: echo "Twelve" ; break ; case 13: echo "Thirteen" ; break ; case 14: continue 2; case 15: echo "Fifteen" ; break ; } echo " < br > Below switch, and i = " . $i . '< br > < br > ' ; }
    ?>
    Output: