Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: Next operator

  1. #1
    Regular Coder dswimboy's Avatar
    Join Date
    Nov 2003
    Location
    mostly in Ann Arbor
    Posts
    458
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Next operator

    perl has a next operator, such that while working in a foreach, while loop, you can skip to the next iteration if a condition is met.

    i see PHP has a next function, but i am not sure if i should use it the same, or not.

    those of you familiar with Perl, could you help me?
    "There is more than one way to do it."

  • #2
    Regular Coder
    Join Date
    Apr 2004
    Posts
    298
    Thanks
    0
    Thanked 23 Times in 23 Posts
    from: http://php3.de/manual/en/control-str...s.continue.php


    continue
    continue is used within looping structures to skip the rest of the current loop iteration and continue execution at the beginning of the next iteration.

    Note: Note that in PHP the switch statement is considered a looping structure for the purposes of continue.

    continue accepts an optional numeric argument which tells it how many levels of enclosing loops it should skip to the end of.



    <?php
    while (list ($key, $value) = each ($arr)) {
    if (!($key % 2)) { // skip odd members
    continue;
    }
    do_something_odd ($value);
    }

    $i = 0;
    while ($i++ < 5) {
    echo "Outer<br />\n";
    while (1) {
    echo "&nbsp;&nbsp;Middle<br />\n";
    while (1) {
    echo "&nbsp;&nbsp;Inner<br />\n";
    continue 3;
    }
    echo "This never gets output.<br />\n";
    }
    echo "Neither does this.<br />\n";
    }
    ?>



    Omitting the semicolon after continue can lead to confusion


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •