➤ 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
*/