➤ The continue statement breaks one iteration (in the loop), if a specified condition occurs, and continues with the next iteration in the loop.
// This example skips the value of 2
for ($a = 0; $a < 4; $a++) {
  if ($a == 2) {
    continue;
  }
  echo "The number is: $a \n";
} 
/* outputs:  The number is: 0 
	     The number is: 1 
	     The number is: 3
*/


// We print array elements by omitting "Audi".
$cars = array("BMW","Audi","Porsche");
foreach ($cars as $val) {
	if ($val == "Audi") {
		continue;
	}
	echo "$val \n";
}
/* outputs:  BMW
             Porsche
*/
by Levani Makhareishvili
2 years ago
PHP
Loops
1
Pro tip: use ```triple backticks around text``` to write in code fences
0
Valeri Tandilashvili 2 years ago
Test comment
REPLY