Easy questions about odds and evens
Posted: Mon Feb 16, 2004 5:56 pm
Can someone point me in the direction of checking a value for odd or even?
Thanks
Rand
Thanks
Rand
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
if ($num % 2 == 0) {
//number is even
}else{
//number is odd
}Code: Select all
<?php
function oddeven($numvalue){
if($numvalue & 1) return "odd";
else return "even";
}
?>Code: Select all
$num % 2Do I feel some kind of agressivity ?Illusionist wrote:yeah, your right, but no one asked what it meant... ?!?!
Dr Evil, I feel our young friend needs a cup of tea to learn to relax a bit.Dr Evil wrote:Do I feel some kind of agressivity ?Illusionist wrote:yeah, your right, but no one asked what it meant... ?!?!