Re: how to say "inverse your value" (to a boolean)?
| From: | Paul M Foster | Date: | Tue, 11 Aug 2009 02:18:02 +0000 |
| Subject: | Re: how to say "inverse your value" (to a boolean)? | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-296600@lists.php.net to get a copy of this message | ||
On Mon, Aug 10, 2009 at 04:18:29PM -0700, Daevid Vincent wrote:
> NO! For the love of God and all that is holy, don't do that accumulator /
> mod "hack".
> That's sooooo 1980's. And why make the CPU do all that math for every row...
>
> Just do this. It's quick and simple:
>
> CSS:
> .dataRow1 { background-color: #DFDFDF; }
> .dataRow2 { background-color: #FFFFFF; }
>
> foreach ($foo_array as $foo) {
> ?><tr class="<?= ($dr = !$dr) ? "dataRow1" : "dataRow2"
> ?>"><td><?= $foo
> ?></td></tr><?php
> }
NO! For the love of God and all that is holy, don't do that <?= "hack".
That's sooooo 1990's.
Just do this. It's quick and simple:
<tr class="<?php echo ($dr = !$dr) ? "dataRow1" : "dataRow2"
?>">
(I just couldn't resist! ;-)
Paul
--
Paul M. Foster