Home  >  Article  >  Backend Development  >  PHP flow control break statement

PHP flow control break statement

不言
不言Original
2018-05-04 09:46:271498browse

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(&#39;one&#39;, &#39;two&#39;, &#39;three&#39;, &#39;four&#39;, &#39;stop&#39;, &#39;five&#39;);
while (list (, $val) = each($arr)) {
    if ($val == &#39;stop&#39;) {
        break;    /* You could also write &#39;break 1;&#39; 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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn