Home > Backend Development > PHP Tutorial > Usage of PHP function continue in loop structure_PHP tutorial

Usage of PHP function continue in loop structure_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-15 13:29:29
Original
834 people have browsed it

What makes our actual PHP continue function different is that it accepts an optional numeric parameter to decide how many loops to skip to the end of the loop.

In PHP, continue is used in a loop structure to skip the remaining code in this loop and start executing the next loop. This is consistent with other languages, but there's another twist: continue accepts an optional numeric argument to determine how many loops to skip to the end of the loop.

<ol class="dp-xml">
<li class="alt"><span><span>#php_continue.php  </span></span></li>
<li class=""><span> </span></li>
<li class="alt">
<span>$</span><span class="attribute"><font color="#ff0000">i</font></span><span> = </span><span class="attribute-value"><font color="#0000ff">0</font></span><span>;  </span>
</li>
<li class="">
<span>$</span><span class="attribute"><font color="#ff0000">j</font></span><span> = </span><span class="attribute-value"><font color="#0000ff">0</font></span><span>;  </span>
</li>
<li class="alt">
<span>while ($i++ </span><strong><font color="#006699"><span class="tag"><</SPAN><SPAN class=tag-name>3</SPAN></FONT></STRONG><SPAN>) {//level 3  </SPAN></SPAN><LI class=""><SPAN>echo "Outer  </SPAN><LI class=alt><SPAN>n";  </SPAN><LI class=""><SPAN>while (1){//level 2  </SPAN><LI class=alt><SPAN>echo "Middle  </SPAN><LI class=""><SPAN>n";  </SPAN><LI class=alt><SPAN>while (1){//level 1  </SPAN><LI class=""><SPAN>echo "Inner  </SPAN><LI class=alt><SPAN>n";  </SPAN><LI class=""><SPAN>continue 3;  </SPAN><LI class=alt><SPAN>}  </SPAN><LI class=""><SPAN>echo "Thisnever gets output.  </SPAN><LI class=alt><SPAN>n";  </SPAN><LI class=""><SPAN>}  </SPAN><LI class=alt><SPAN>echo"Neither does this.  </SPAN><LI class=""><SPAN>n";  </SPAN><LI class=alt><SPAN>$j++;  </SPAN><LI class=""><SPAN>//after runscontinue 3,it comes to the end of level 3  </SPAN><LI class=alt><SPAN>}  </SPAN><LI class=""><SPAN>echo"$</SPAN><SPAN class=attribute><FONT color=#ff0000>j</FONT></SPAN><SPAN>=$j";//output: $</SPAN><SPAN class=attribute><FONT color=#ff0000>j</FONT></SPAN><SPAN>=</SPAN><SPAN class=attribute-value><FONT color=#0000ff>0</FONT></SPAN><SPAN> </SPAN></SPAN><LI class=alt><SPAN></SPAN><SPAN class=tag><STRONG><FONT color=#006699>?></span></font></strong><span> </span>
</li>
</ol>
Copy after login

The above code is the specific usage of PHP function continue. I hope it will be helpful to everyone. helped.


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/446358.htmlTechArticleWhat makes our actual PHP function continue different is that it accepts an optional numeric parameter to decide to skip Several loops to the end of the loop. In php, continue is used in loop structures...
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template