PHP break and continue two Process Control instruction difference Analysis _php skill

Source: Internet
Author: User
The following examples illustrate
The break is used to jump out of the current execution loop and no longer executes the loop.
Copy Code code as follows:

<?php
$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 to continue the next loop.
Copy Code code as follows:

<?php
while (the list ($key, $value) = each ($arr)) {
if ($key = = "Zhoz") {//If the value of the query to the object is equal to Zhoz, the record is not displayed.
Continue
}
Do_something ($value);
}
Example 2
foreach ($list as $temp) {
if ($temp->value = = "Zhoz") {
Continue If the value of the query to the object equals Zhoz, the record is not displayed.
}
Do_list; This shows the records in the array
}
?>

Note: You cannot use goto loop instructions in PHP.

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.