Mombu the Php Forum

Go Back   Mombu the Php Forum > Php > isodd() php5?
User Name
Password
REGISTER NOW! Mark Forums Read




Reply
1 23rd October 19:34
ross
External User
 
Posts: 1
Default isodd() php5?



Hi,

Is there a built in function in PHP5 to determine if an integer is even or
odd?


Ross
  Reply With Quote


 


2 23rd October 19:34
networkadmin
External User
 
Posts: 1
Default isodd() php5?



How about :

if ($IntegerValue % 2) {
// odd
} else {
// even
}

HTH
J
  Reply With Quote
3 23rd October 19:35
tedd.sperling
External User
 
Posts: 1
Default isodd() php5?


Try:

echo($integer & 1);

1 = odd, 0 = even.

Cheers,

tedd


--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
  Reply With Quote
Reply


Thread Tools
Display Modes




666