<div class="codetitle"> <span><a style="CURSOR: pointer" data="55889" class="copybut" id="copybut55889" onclick="doCopy('code55889')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code55889"> <br>//php当前循环为1,循环由里到外依次递增,break默认为1,例如跳出第2层循环<br>for ($i=0;$i<3;$i ){<BR> foreach (array(1,2,3) as $val){ <BR> foreach (array(1,2,3) as $val){ <BR> echo "1层循环<br/>"; <br> break 2; //跳出第2层循环 <br> }<br> echo "2层循环<br/>";<br> }<br> echo "3层循环<br/>";<br>}<br>//结果:<br>//1层循环<br>//3层循环<br>//1层循环<br>//3层循环<br>//1层循环<br>//3层循环<br> </div>