title: Should I return from within a foreach loop
body: <p>I see plenty of code examples where the user is returning from within a foreach loop, but is it bad form to do this?  Does it leave any orphaned references, for example?</p>
  
  <p>Here's an example:</p>
  
  <pre><code>$array = array(1, 2, 4, 8, 16);    
  foreach ($array as $value) {
    if ($value == 8) return true; 
  }
  return false;
  </code></pre>
  
  <p>EDIT: This is quite different from its supposedly duplicate question, simply by the fact that it focuses on the <code>return</code> instruction, not the <code>break</code>, <code>continue</code>, <code>goto</code>, or any other instruction.  Users who are searching for the answer to this question will no necessarily search for the supposed alternatives.  In my case, it didn't event occur to me to think them through.  Even if I had I would not have come up with an exhaustive list.</p>