title: Break out out forloop but within switch statement php
body: <p>When I normally want to break out of a foreach loop before all of the iterations have completed I simply use a break; statement. e.g.</p>
  
  <pre><code>foreach($nodelist as $node) {
     if($metCriteria) {
         break;
     }
  }
  </code></pre>
  
  <p>But my next example has a switch statement in it. And if one of the conditions are met then I need to break from the foreach loop. (The problem being the break is used for the switch statement)</p>
  
  <pre><code>foreach($nodelist as $node)
  {
      switch($node-&gt;nodeName) {
          case "a" :
              //do something
              break;
          case "b" :
              //break out of forloop
              break;
      }
  }
  </code></pre>
  
  <p><strong>Do I simply set a variable in the switch statement then break after it? e.g.</strong></p>
  
  <pre><code>$breakout = false;
  foreach($nodelist as $node)
  {
      switch($node-&gt;nodeName) {
          case "a" :
              //do something
              break;
          case "b" :
              $breakout = true;
              break;
      }
      if($breakout === true) break;
  }
  </code></pre>
  
  <p><strong>Is this the best solution? or this there another way?</strong></p>