Home > Article > Backend Development > PHP flow control break statement
This article mainly introduces the break of PHP process control, which has certain reference value. Now I share it with everyone. Friends in need can refer to it.
This article is used for basic purposes. Learners, experts please close this page
It takes 12 minutes to read this article, it is difficult to understand
<?php $arr = array('one', 'two', 'three', 'four', 'stop', 'five'); while (list (, $val) = each($arr)) { if ($val == 'stop') { break; /* You could also write 'break 1;' here. */ } echo "$val<br />\n"; } /* 使用可选参数 */ $i = 0; while (++$i) { switch ($i) { case 5: echo "At 5<br />\n"; break 1; /* 只退出 switch. */ case 10: echo "At 10; quitting<br />\n"; break 2; /* 退出 switch 和 while 循环 */ default: break; } } ?>
Related recommendations :
php process control what is foreach
php process control the for statement
php process control of do-while
The above is the detailed content of PHP flow control break statement. For more information, please follow other related articles on the PHP Chinese website!