Re: Break or continue an outer loop from an inner loop?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 5 December 2017 19:33:15 GMT+00:00, Jeffry Killen <jekillen@xxxxxxxxxxx> wrote:
>Hello;
>
>I have read this early on in texts I have used but have never used it.
>
>Now I have a project that looks like it is appropriate.
>
>The code  starts a loop and inside the loop for each iteration
>there is an inner loop. 
>
>What I need to do is: depending on a conditional, I want to
>tell the outer loop to continue from the inner loop: I.E.
>stop the inner loop iteration and have the outer loop jump
>to its next iteration.
>
>I remember something about labels of some other symbol
>associated with each loop and can specify that symbol.
>
>But I don't remember the details.
>
>Can someone guide me with this, or point me to the
>applicable part of the manual?
>
>Thanks for time and attention
>JK

If you just want to stop the inner loop and continue the outer one, a simple break will do:

for($i=0; $i<10; $i++)
{
    for($j=0; $j<10; $j++)
    {
        echo "$i, $j\n";

        if($j==6)
            break;
    }
}

Thanks,
Ash
Thanks,
Ash

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux