Continue
The Continue is used in the loop structure to skip the remaining code in this loop and start the next loop.
Note: Notice that the switch statement is considered a looping structure for continue purposes in the PHP tutorial.
Continue accepts an optional numeric parameter to decide to skip a few loops to the end of the loop.
<?php while (list ($key, $value) = each ($arr)) { if ($key = = "Zhoz") { //If the value of the queried object is equal to Zhoz, the record is not displayed. continue; } Do_something ($value); }
Example 2
<?phpforeach ($list as $temp) { if ($temp->value = = "Zhoz") { continue; If the value of the query to an object equals Zhoz, the record is not displayed. } do_list; This shows the records in the array}
Break
Break ends Current For,foreach,while,do: The execution of the while or switch structure.
Break can accept an optional numeric parameter to decide to jump out of a few loops.
<?php$arr = Array (' One ', ' one ', ' one ', ' three ', ' four ', ' Stop ', ' five ') and while (list (, $val) = each ($arr)) { if ($val = = ' Stop ') {break ; /* You could also write ' break 1; */ } echo "$val <br>n";} /* Using the optional argument. */$i = 0;while (+ + $i) { switch ($i) {case 5: echo ' at 5<br>n '; Break 1; /* Exit only the switch. * /Case: Echo ' at 10; Quitting<br>n "; Break 2; /* Exit the switch and the while. * /default: Break ; }}? >
Example two
<?php $i = 0; while ($i < 7) { if ($arr [$i] = = "Stop") {break ; } $i + +;}?>