title: for each ... break
body: <p>I feel dirty every time I "break" out of a for-each construct (PHP/Javascript) </p>
  
  <p>So something like this:</p>
  
  <p>// Javascript example</p>
  
  <pre><code>for (object in objectList)
  {
     if (object.test == true)
     {
        //do some process on object
        break;
     }
  
  }
  </code></pre>
  
  <p>For large objectLists I would go through the hassle building a more elegant solution.  But for small lists there is no noticeable performance issue and hence "why not?"  It's quick and more importantly easy to understand and follow.</p>
  
  <p>But it just "feels wrong".  Kind of like a goto statement.</p>
  
  <p>How do you handle this kind of situation?</p>