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.
Where have I gone wrong?
Updated Code sample in response to first comment.
foreach ($this->routes as $route => $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 < $count; $i++) {
if ($route_segments[$i] != $segments[$i] && ! preg_match('/^\x24[0-9]+$/', $route_segments[$i])) {
$continue = 34;
continue;
}
}
echo $continue; die(); // Prints out 34
$continue
. It is entirely possible to enter that it gets set to 1, then 2 in your loop iterations.$continue = 0;
right after theforeach
... I'll bet you won't get1
anymore. A for 2, you'd need to tell it to continue up 2 levels, socontinue 2;
, otherwise it'll just go to the next iteration of thefor
loop...