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

From: Date: Mon, 10 Aug 2009 22:41:32 +0000
Subject: Re: how to say "inverse your value" (to a boolean)?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-296575@lists.php.net to get a copy of this message
You can do this... for( $b=true; <your-statement>; $b = !$b ) { <your-code> } I usually use this solution.... $types = array( 'one', 'two' ); foreach( $list as $item ) # <-- your set of (many) items { echo current( $types ); # <-- this prints the current class # code next( $types ) or reset( $types ); # and this do the magic } Hey! look, this solution can work with more than 2 types... try it with many types: $types = array( 'one', 'two', three', 'four' ); On Mon, Aug 10, 2009 at 7:16 PM, John Butler <govinda.webdnatalk@gmail.com>wrote: > quick Q: > I have this inside a foreach{} that I want to alternate between on and off > so I can alternate the background-color of my <tr>'s. > > $tableRowBGcolorBoolCounter != $tableRowBGcolorBoolCounter; //-boolean on > and off > > I am looking thru' docs and books, but can't remember (nor find now) in PHP > how to say "inverse your value" (to a boolean). > ? > > TIA! -G > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Martin Scotta

« previous php.general (#296575) next »