break
完全结束一个循环,continue
只是在当前迭代中设置捷径,然后继续下一个迭代.
while ($foo) { <--------------------┐
continue; --- goes back here --┘
break; ----- jumps here ----┐
} |
<--------------------┘
这样使用:
while ($droid = searchDroids()) {
if ($droid != $theDroidYoureLookingFor) {
continue; // ..the search with the next droid
}
$foundDroidYoureLookingFor = true;
break; // ..off the search
}