Re: even or not
| From: | Morten Winkler Jørgensen | Date: | Tue, 13 Nov 2001 09:22:32 +0000 |
| Subject: | Re: even or not | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-74393@lists.php.net to get a copy of this message | ||
OSv> How can is check with php wether a number is even or not? What i want is
OSv> that in a while loop the background color of a cell changes!
Try
echo (($i++ % 2) == 0) ? "#FF0000<BR>" : "#00FF00<BR>";
First it performs an integerdivision and checks if the remainder is 0.
If that is the case it prints "FF0000" if the remainder is 1 it prints
"00FF00"
Finally is increments $i.
--
Kind regards,
Morten Winkler