In common for and foreach loops in php, conditions are often judged or aborted. The processing method mainly uses the break and continue process control commands. The main differences are as follows:
Break is used to jump out of the current execution cycle and stop executing the loop.
The code is as follows:
$ I = 0;
While ($ I <7 ){
If ($ arr [$ I] = "stop "){
Break;
}
$ I ++;
}
?>
Continue immediately stops the current execution cycle, returns to the condition judgment of the loop, and continues the next loop.
The code is as follows:
While (list ($ key, $ value) = each ($ arr )){
If ($ key = "zhoz") {// if the queried object value is zhoz, this record will not be displayed.
Continue;
}
Do_something ($ value );
}
// Example 2
Foreach ($ list as $ temp ){
If ($ temp-> value = "zhoz "){
Continue; // if the queried object value is zhoz, this record will not be displayed.
}
Do_list; // records in the array are displayed here.
}
?>
Note: The goto loop command cannot be used in PHP.