Re: how to say "inverse your value" (to a boolean)?
| From: | Jim Lucas | Date: | Mon, 10 Aug 2009 23:03:13 +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-296581@lists.php.net to get a copy of this message | ||
John Butler 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
$arr = range(1, 10);
$i = 0;
foreach ( $arr AS $row ) {
$row_color = ( ( $i++ % 2 ) ? 'green' : 'red');
echo $row_color;
}
?>