Re: question
| From: | Don Read | Date: | Sun, 30 Mar 2003 13:19:40 +0000 |
| Subject: | Re: question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-141638@lists.php.net to get a copy of this message | ||
On 30-Mar-2003 skate wrote:
> excuse me for being dumb, but can you explain this line for me?
>
> if (! (++$i % 2))
>
If $i is evenly divisible by 2 then ($i % 2) evaluates to 0 or (false).
The (! ($i % 2)) inverts the meaning to (true) so the statements within
the if block are executed.
The ++$i bit --well it's a handy spot to increment $i, and the pre-increment
notation gets around the case when $i == 0.
Regards,
--
Don Read dread@texas.net
-- It's always darkest before the dawn. So if you are going to
steal the neighbor's newspaper, that's the time to do it.