title: php foreach continue
body: <p>I am trying to skip to the next iteration of the loop if certain conditions are not met. The problem is that the loop is continuing regardless.</p>
  
  <p>Where have I gone wrong?</p>
  
  <p>Updated Code sample in response to first comment.</p>
  
  <pre><code>    foreach ($this-&gt;routes as $route =&gt; $path) {
          $continue = 0;
  
          ...
  
          // Continue if route and segment count do not match.
          if (count($route_segments) != $count) {
              $continue = 12;
              continue;
          }
  
          // Continue if no segment match is found.
          for($i=0; $i &lt; $count; $i++) {
              if ($route_segments[$i] != $segments[$i] &amp;&amp; ! preg_match('/^\x24[0-9]+$/', $route_segments[$i])) {
                  $continue = 34;
                  continue;
              }
          }
  
          echo $continue; die(); // Prints out 34
  </code></pre>