PHP Odd Number
To check a number for oddness
in PHP, simply find the remainder of dividing this
number by 2. If this remainder is 0 -
the number is even, and if it's 1 - it's odd. The remainder
of division can be found using the % operation. See the
example:
<?php
$num = 3;
if ($num % 2 == 0) {
echo 'even';
} else {
echo 'odd';
}
?>