Home  >  Article  >  Backend Development  >  About the problem of php loop jumping_PHP tutorial

About the problem of php loop jumping_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:01:47981browse

Copy the code The code is as follows:

//The current loop of php is 1, and the loop increases from the inside to the outside. The default break is 1. For example, jump out of the second level loop
for ($i=0;$i<3;$i++){
foreach (array(1,2,3) as $val){
foreach (array( 1,2,3) AS $ Val) {
Echo "1 layer of cycle & lt; br/& gt;";
Break 2; // Jump out of the second layer of loop
}
echo "2 Layer loop
";
}
echo "3-layer loop
";
}
//Result:
//1-layer loop
//3-layer loop
//1-layer loop
//3-layer loop
//1-layer loop
//3-layer loop

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327959.htmlTechArticleCopy code The code is as follows: //php current loop is 1, the loop increases from inside to outside, break defaults to 1. For example, jump out of the second level loop for ($i=0;$i3;$i++){ foreach (array(1,2,3) as $val){...
Statement:
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