Re: Break or continue an outer loop from an inner loop?
| From: | Ashley Sheridan | Date: | Tue, 05 Dec 2017 19:45:43 +0000 |
| Subject: | Re: Break or continue an outer loop from an inner loop? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-326291@lists.php.net to get a copy of this message | ||
On 5 December 2017 19:33:15 GMT+00:00, Jeffry Killen <jekillen@prodigy.net> 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