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

PHP flow control break statement

不言
Release: 2023-03-25 11:00:01
Original
1529 people have browsed it

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;
    }
}
?>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template