Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking numbers

Status
Not open for further replies.

DeepBlerg

Technical User
Jan 13, 2001
224
AU
Just another quick one,

Is there a way in PHP to check if a number is even or odd?

For example, in a:

while ($i < $numRows) {
do stuff
}

I'd like it to change the color of the text to red if $numRows is an even number and have black text for all the odd numbers.
 
There is a math way:


while ($i < $numRows) {

if ($i % 2 = 0)
turnColor(black);
else
turnColor(red);
}

Good luck mcvdmvs
-- &quot;It never hurts to help&quot; -- Eek the Cat
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top