Home > php教程 > php手册 > 关于php循环跳出的问题

关于php循环跳出的问题

WBOY
Release: 2016-06-06 20:28:46
Original
1346 people have browsed it

本篇文章是对php中循环跳出的问题进行了详细的分析介绍,需要的朋友参考下

复制代码 代码如下:


//php当前循环为1,循环由里到外依次递增,香港服务器租用,break默认为1,免备案空间,香港服务器,例如跳出第2层循环
for ($i=0;$i    foreach (array(1,2,3) as $val){    
        foreach (array(1,2,3) as $val){         
            echo "1层循环
"; 
            break 2;  //跳出第2层循环        
        }
        echo "2层循环
";
    }
    echo "3层循环
";
}
//结果:
//1层循环
//3层循环
//1层循环
//3层循环
//1层循环
//3层循环

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template