Re: how to say "inverse your value" (to a boolean)?

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

 



2009/8/11 Daevid Vincent <daevid@xxxxxxxxxx>:

> 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
> }

A change request just came in - the interaction designer wants every
third line to have a grey background, instead of every second line.

> No need to initialize $dr as by default PHP will make it a boolean "false",
> then each itteration, it will toggle true/false and substitute the CSS class

Um. No. Just no.

-- 
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