PHP Continue Statement

When we want to skip to the next iteration of the loop that is currently being executed, we use the continue statement. Thus, whenever the control reaches the continue statement, the loop being executed skips the current iteration, and the control goes to the following iteration. For example

It lets you prematurely end the current iteration of a loop and move on to the next iteration.

The continue statement causes the execution of the current loop iteration to end and commence at the beginning of the next iteration. For example, execution of the following while the body will recommence if $usernames[$x] is found to have the value missing:


 $usernames = array("Grace","Doris","Gary","Nate","missing","Tom"); 
 for ($x=0; $x < count($usernames); $x++) { 
 if ($usernames[$x] == "missing") continue; 
 printf("Staff member: %s <br />", $usernames[$x]); 



Staff member: Grace Staff member: Doris Staff member: Gary Staff member: Nate Staff member: Tom