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

From: Date: Tue, 11 Aug 2009 10:38:50 +0000
Subject: Re: how to say "inverse your value" (to a boolean)?
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-296618@lists.php.net to get a copy of this message
seems they changing idears on the fly? could it be that the designer is a smal ugly person while u a a good looking ladykiller ? on that background I would design a function where u can change ti what ever u want on the fly something like this var $a; function alternate( $a, $_b=array( "red", "red" ,"green" ,... ) { if( count( $_b ) > $a ) { return $_b[ $a++ ] ; } $a=0; return $_b[ $a++ ] ; } so now u can do what ever anybody wants on just putting the right values into the array cheers ralph ralph_deffke@yahoo.de "David Otton" <phpmail@jawbone.freeserve.co.uk> wrote in message news:193d27170908110328p43b4722fkc46b0bcda97fcf48@mail.gmail.com... 2009/8/11 Daevid Vincent <daevid@daevid.com>: > 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.

« previous php.general (#296618) next »