通过在循环中使用 break 关键字,我们可以在 PHP 的任何地方终止或者中断循环。
中断 PHP 循环的示例:
<?php
$months = array('jan', 'feb', 'mar', 'apr', 'stop', 'may');
foreach ($months as $month) {
if ($month == 'stop') {
break;
}
echo "$month<br />";
}
?>
日期:2020-09-17 00:10:25 来源:oir作者:oir
