Question about php loop jump _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
The php loop jumps out. Copy the code as follows: the current php loop is 1, and the loop increments from the inside to the outside. the default break is 1, for example, jumping out of the 2nd-layer loop for ($ i0; $ i3; $ I ++) {foreach (array (1, 2, 3) as $ val ){ The code is as follows:


// The Current php loop is 1, and the loop increases sequentially from the inside to the outside. the default break is 1, for example, 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 "layer-1 loop
";
Break 2; // jump out of the 2nd-layer loop
}
Echo "layer-2 loop
";
}
Echo "Layer 3 loop
";
}
// Result:
// Layer-1 loop
// Layer-3 loop
// Layer-1 loop
// Layer-3 loop
// Layer-1 loop
// Layer-3 loop

The http://www.bkjia.com/PHPjc/327959.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/327959.htmlTechArticle code is as follows: // php the current loop is 1, the cycle increments from inside to outside, break defaults to 1, for example, jumping out of the 2nd layer loop for ($ I = 0; $ i3; $ I ++) {foreach (array (1, 2, 3) as $ val ){...

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.