Re: how to say "inverse your value" (to a boolean)?
| From: | tedd | Date: | Tue, 11 Aug 2009 14:13:07 +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-296630@lists.php.net to get a copy of this message | ||
At 10:27 AM -0300 8/11/09, Martin Scotta wrote:
A change request just came in - the interaction designer wants every third line to have a grey background, instead of every second line. # before was $styles = array( 'even', 'odd' ); # after new requirements it is... $styles = array( 'white', 'white', 'gray' ); foreach($items as $item) { printf( '<li class="%s">%s</li>', current( $styles ), $item ); next( $styles ) or reset( $styles ); } The simplest solution is always the best choice. This provides maintainability and flexibility to changes ( that we don't know yet ) -- Martin ScottaThe "simplest solution" is in the eyes of the beholder. My solution was the simplest for the problem presented. You presented a different problem with a different solution. Cheers, tedd -- ------- http://sperling.com http://ancientstones.com http://earthstones.com