title: Can you 'exit' a loop in PHP?
body: <p>I have a loop that is doing some error checking in my PHP code. Originally it looked something like this...</p>
  
  <pre><code>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
  }
  </code></pre>
  
  <p>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?</p>