Usage of PHP function continue in loop structure _ PHP Tutorial

Source: Internet
Author: User
Usage of PHP function continue in the loop structure. The difference between the actual PHP function continue is that we accept an optional numeric parameter to decide to skip several repeated loops to the end of the loop. In php, continue is used in the loop structure in our actualThe difference between the PHP function continue is that it accepts an optional numeric parameter to decide to skip several repeated loops to the end of the loop.

In php, continue is used in the loop structure to skip the remaining code in this loop and start executing the next loop. This is the same as that in other languages. However, the other trick is that continue accepts an optional numeric parameter to decide to skip several iterations to the end of the loop.

 
 
  1. #php_continue.php
  2. $i = 0;
  3. $j = 0;
  4. while ($i++ <3) {//level 3
  5. echo "Outer
  6. n";
  7. while (1){//level 2
  8. echo "Middle
  9. n";
  10. while (1){//level 1
  11. echo "Inner
  12. n";
  13. continue 3;
  14. }
  15. echo "Thisnever gets output.
  16. n";
  17. }
  18. echo"Neither does this.
  19. n";
  20. $j++;
  21. //after runscontinue 3,it comes to the end of level 3
  22. }
  23. echo"$j=$j";//output: $j=0
  24. ?>

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


The unique feature of the pipeline PHP function continue is that it accepts an optional numeric parameter to decide to skip several repeated loops to the end of the loop. In php, continue is used in the loop structure...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.