php foreach continue
如果不满足某些条件,我将尝试跳到循环的下一个迭代。问题是循环仍在继续。
我哪里做错了?
更新了代码示例以响应第一条评论。
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