Hello and welcome to our community! Is this your first visit?
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
    mostly in Ann Arbor
    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
    Thanked 23 Times in 23 Posts
    from: http://php3.de/manual/en/control-str...s.continue.php

    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.

    while (list ($key, $value) = each ($arr)) {
    if (!($key % 2)) { // skip odd members
    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