Re: a for-loop syntax question
| From: | HKG) | Date: | Mon, 12 Jan 2004 14:13:30 +0000 |
| Subject: | Re: a for-loop syntax question | ||
| References: | 1 2 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-22558@lists.php.net to get a copy of this message | ||
On Mon, 2004-01-12 at 15:11, Svensson, B.A.T. (HKG) wrote:
> On Mon, 2004-01-12 at 15:07, Bobo Wieland wrote:
> > Hi...
> >
> > Is there a way to set a for loop to exit when the FIRST of many
> > expresions evaluate to false?
> >
> > the code: for ($i = 0, $j = 0; $i < 10, $j < 5; $i++, $j++) {} will
> > execute 10 times, but i was hoping it would exit when $j was set to 5...
> > Is there some way of doing this?
> >
> >
> > .bobo
>
>
> Does this do what you want:
>
> for ($i = 0, $j = 0; $j = 5, $i < 10, $j < 5; $i++, $j++)
>
> or are you looking for something like this:
>
> for ($i = 0, $j = 0; (!($j = 5) || $i < 10 || $j < 5); $i++, $j++)
ERRATA:
for ($i = 0, $j = 0; (!($j = 5) && $i < 10 && $j < 5); $i++, $j++)