Continue statement difference analysis of break and continue two flow control instructions in PHP

Source: Internet
Author: User
The following examples illustrate
Break is used to jump out of the current execution loop and no longer executes the loop.

Copy the Code code as follows:


$i = 0;
while ($i < 7) {
if ($arr [$i] = = "Stop") {
Break
}
$i + +;
}
?>


Continue immediately stops the current execution loop and returns to the loop's conditional judgment, continuing the next loop.

Copy the Code code as follows:


while (list ($key, $value) = each ($arr)) {
if ($key = = "Zhoz") {//If the value of the queried object is equal to Zhoz, the record will not be displayed.
Continue
}
Do_something ($value);
}
Example 2
foreach ($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
}
?>


Note that the goto loop instruction is not available in PHP.

The above describes the continue statement PHP break and continue two process control instructions, including the content of the continue statement, I hope that the PHP tutorial interested in a friend helpful.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.