📜  foreach 跳过当前迭代 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:11.002000             🧑  作者: Mango

代码示例1
// You can skip the current iteration using "continue"
// Example: Skip the current iteration if $number is 3;
$numbers = [1, 2, 3, 4, 5];

foreach($numbers as $number) {
    if($number == 3) {
        continue;
    }
    echo $number . " + ";
}
// output: 1 + 2 + 4 + 5 +