odd or even number
Moderator: General Moderators
- shiznatix
- DevNet Master
- Posts: 2745
- Joined: Tue Dec 28, 2004 5:57 pm
- Location: Tallinn, Estonia
- Contact:
odd or even number
is there a way to tell if a number is odd or even? i am creating a table from a db but i was the css to go with it with the diffrent color rows for each and all that. im sure this is a easy one but my google search turned up nothing
use this little function
or
or
Code: Select all
function oddeven($x){
if($x & 1) return "odd";
else return "even";
}Code: Select all
if ($number % 2) {
// Odd
} else {
// Even
}