About the PHP loop jumping out of the question

Source: Internet
Author: User
Tags foreach
This article is on the PHP loop out of the issue of a detailed analysis of the introduction, the need for a friend to copy code below the reference code:


PHP's current loop is 1, the loop is incremented from inside to outside, and the break defaults to 1, such as jumping out of the 2nd layer loop
For ($i =0 $i <3; $i + +) {
foreach (Array (1,2,3) as $val) {
foreach (Array (1,2,3) as $val) {
echo "1-layer cycle <br/>";
Break 2; Jump out of the 2nd floor loop
}
echo "2-layer cycle <br/>";
}
echo "3-layer cycle <br/>";
}
Results:
1-Layer Cycle
3-Layer Cycle
1-Layer Cycle
3-Layer Cycle
1-Layer Cycle
3-Layer Cycle

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.