Re: Alternate Colors in Rows

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

 



As you can see, a bunch of different ways to skin this particular cat.

For fun, I wanted to show you something I came up with early in my PHP 
career.  It's kinda dumb and some of the other ways shown are easier to 
understand right off the bat, but here is an "alternate" way to do it.

My initial though (and again, I was brand new to PHP) was that I could toggel 
between 1 and 0 using a logical "NOT" type command.  It didn't really work 
the way I thought it was going to, but in a fashion it did.

I don't have code in front of me, so forgive any minor errors but it was 
something like this:

$colors[-1] = "#DDDDDD"; //  or any other way you care to build the array, 
but 
$colors[0] = "#FFFFFF";      // but we're using 0 and -1 since it didn't work 
the way I thought with 1

$toggle = 0;

echo "Color1 = " . $colors[$toggle];
$toggle = ~$toggle;
echo "Color2 = " . $colors[$toggle];
$toggle = ~$toggle;
echo "Color1again = " . $colors[$toggle];


Anyway, really crude example, but that's what my new-to-PHP brain came up 
with.   The MOD (%) ways are probably the easiest unless there's some "NOT" 
way that I never bothered to investigate.

I haven't had to do the alternating color thing too many times so never 
really went back to re-think the NOT or the MOD ways to see if there's a 
better way.

Just thought I'd present kind of an odd way to see if it sparks some ideas 
for anyone.

-TG

----- Original Message -----

> Steve Marquez wrote:
> > Greetings,
> > 
> > I am attempting to alternate the colors of the container DIV. Anyone know
> > how to do this? 
> > 
> > Thank you very much,
> > 
> > --
> > Steve M.
> > 

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