Re: array loops

From: Date: Sat, 02 Dec 2000 04:56:59 +0000
Subject: Re: array loops
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-28340@lists.php.net to get a copy of this message
I know Im beeing picky here, but what is $i is 5?
Sorry - I forgot to post the email I was replying to. We were just talking about an easy way to do those table-rows-switching-color things. Where you really do just want to set either "$color=#FFFFFF" or "$color=#CCCCCC" A simple on/off. either/or. It wasn't meant to be a big generic solution for any variable changing.
At 07:15 AM 12/1/00 , you wrote:
while(....)
        {
        $i =+ 1;
        $i % 2 ? print "color 1" : "color 2";
        }
Another method is: $i = 1-$i So it just keeps flagging back and forth between 1 and 0.


« previous php.general (#28340) next »