PHP continue

 PHP continue is used to skip the remaining loop code of the loop. If the loop condition is not over, it will continue to run the next loop. Assuming that there is a certain condition in your loop, you need to skip and continue to run back Circle, for example, count the sales quantity of all commodities. If the sales quantity of one commodity cannot be included in this statistics, you can use continue to skip the number of the commodity and continue to count the sales quantity of other commodities, so that you can Automatically filter out this item and complete statistics on the sales of all items at once.


PHP continue example
<?php
for ($i = 0; $i <10; ++$i){
 if ($i == 3){
 continue;
 }
 echo $i; // output result 012456789
}

$i = 0;
while ( $i <10){
 $i++;
 if ($i == 5){
 continue;
 }
 echo $i; // output result 1234678910
}
?>
The first example for loop skips $i=3 through continue and continues to execute from $i=4, so the output result ranges from 0 to 9 and skips 3. The second example is a while loop. The variable starts from $i = 0. At the beginning of the loop, $i + 1 (that is, $i++) is first set. If $i=5 is encountered, it will jump through continue Pass and continue to execute the while loop, so the final output result starts from 1 to 10, of which 5 is skipped. You can also try to skip other digital test results.

Post a Comment

0 Comments