On Fri, 2004-01-16 at 13:17, Jake McHenry wrote:
> I have a random number being generated from 1 to 501, is there an easy way for me to 
> tell if the result is an odd or even number?

Yep. The modulus operator (%). Your number mod 2 will be 1 if it is odd
and 0 if it is even.

http://us4.php.net/manual/en/language.operators.arithmetic.php

if ($your_number % 2) {
  echo 'odd';
} else {
  echo 'even';
}

- Brad

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to