我知道这是一个严重的 ne,但......由于我从谷歌图一来到这里,使其他人感到困惑。
如果他打算从开关中脱出来,而只是结束序号,那么<代码>第2号;将罚款。 <代码>continue 2;将仅继续使用编号,并通过该编号保持编号为continue<>。 d 每次。
Ergo,正确的答案应当是continue 3;
。
http://www.php.net/manual/en/control-polis.continue.php#96945"rel=“noreferer” docs中的评论基本上继续到结构的结束,因为(认为与休息一样)的转变是,在接下来的炉.上 lo。
见。
注
<?php
echo "Hello, World!<pre>";
$numbers= array(1,2,3,4,5,6,7,8,9,0);
$letters = array( a , b , c , d , e , f , g , h , i );
$i = 0;
foreach($letters as $letter) {
++$i;
echo $letter . PHP_EOL;
foreach($numbers as $number) {
++$i;
switch($letter) {
case d :
// So here I want to break; out of the switch, break; out of the
// $numbers loop, and then continue; in the $letters loop.
continue 3; // go to the end of this switch, numbers loop iteration, letters loop iteration
break;
case f :
continue 2; // skip to the end of the switch control AND the current iteration of the number s loop, but still process the letter s loop
break;
case h :
// would be more appropriate to break the number s loop
break 2;
}
// Still in the number s loop
echo " $number ";
}
// Stuff that should be done if the letter is not d .
echo " $i " . PHP_EOL;
}
成果:
Hello, World!
a
1 2 3 4 5 6 7 8 9 0 11
b
1 2 3 4 5 6 7 8 9 0 22
c
1 2 3 4 5 6 7 8 9 0 33
d
e
1 2 3 4 5 6 7 8 9 0 46
f
57
g
1 2 3 4 5 6 7 8 9 0 68
h
70
i
1 2 3 4 5 6 7 8 9 0 81
<代码>continue 2;不仅处理该信的左 lo,而且处理该编号的其余部分(注:$i
在f之后加印。 (......)
Hope that helps anyone else that winds up here first.