I have a loop that is doing some error checking in my PHP code. Originally it looked something like this...
foreach($results as $result) {
if (!$condition) {
$halt = true;
ErrorHandler::addErrorToStack('Unexpected result.');
}
doSomething();
}
if (!$halt) {
// do what I want cos I know there was no error
}
This works all well and good, but it is still looping through despite after one error it needn't. Is there a way to escape the loop?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…