The continue statement stops the current iteration in the while loop and continue with the next.Continue Example Move to next iteration if $x = 4: $x = 0; while($x < 10) { if ($x == 4) { continue; } echo "The number is: $x "; $x++; } Try it Yourself » ADVERTISEMENT...
In awhileloop, the condition is tested, and if it is true, the loop is executed again In afor loop, the increment expression (e.g. i++) is first evaluated, and then the condition is tested to find out if another iteration should be done ...
Break and Continue in While Loop You can also usebreakandcontinuein while loops: Break Example inti=0;while(i<10){System.out.println(i);i++;if(i==4){break;}} Try it Yourself » Continue Example inti=0;while(i<10){if(i==4){i++;continue;}System.out.println(i);i++;} ...
Break and Continue in While Loop You can also usebreakandcontinuein while loops: Break Example inti =0; while(i <10) { cout << i <<"\n"; i++; if(i ==4) { break; } } Try it Yourself » Continue Example inti =0;
Thebreakstatement can also be used to jump out of a loop: Example for(leti =0; i <10; i++) { if(i ===3) {break; } text +="The number is "+ i +""; } Try it Yourself » In the example above, thebreakstatement ends the loop ("breaks" the loop) when the loop counter...