Change language

Difference between break and continue in 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 "
    Below switch, and i = "
    . $i .

     ’
    ; }
    ?>
    Output:

    Shop

    Learn programming in R: courses

    $

    Best Python online courses for 2022

    $

    Best laptop for Fortnite

    $

    Best laptop for Excel

    $

    Best laptop for Solidworks

    $

    Best laptop for Roblox

    $

    Best computer for crypto mining

    $

    Best laptop for Sims 4

    $

    Latest questions

    NUMPYNUMPY

    psycopg2: insert multiple rows with one query

    12 answers

    NUMPYNUMPY

    How to convert Nonetype to int or string?

    12 answers

    NUMPYNUMPY

    How to specify multiple return types using type-hints

    12 answers

    NUMPYNUMPY

    Javascript Error: IPython is not defined in JupyterLab

    12 answers


    Wiki

    Python OpenCV | cv2.putText () method

    numpy.arctan2 () in Python

    Python | os.path.realpath () method

    Python OpenCV | cv2.circle () method

    Python OpenCV cv2.cvtColor () method

    Python - Move item to the end of the list

    time.perf_counter () function in Python

    Check if one list is a subset of another in Python

    Python os.path.join () method