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

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

 



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;

}

?>


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