Here is how to find odd and even numbers in php.
How to find if a number is odd or even?
In PHP I learn to use the MOD (%) operator. see below for an example: $i = 10;
if ($i % 2) {
echo "$i is odd";
} else {
echo "$i is even";
}
You can also use the PHP “&” operator that will give you better performance
You can use the PHP code like so:
$i = 10;
if ( $i&1 )
{
echo "$i is odd";
}
else
{
echo "$i is even";
}
Please rate this post by clicking a star:


(33 votes, average: 4.70 out of 5)
plz tell me how to validate number
Thank you man, it's simplier than I tought!
Great solution .. Way too easy
Use the is_int to validate if a variable is a integer/number.
< ?php
$variable = 1;
if(is_int($variable))
echo "Pass test";
?>
You can view this here:
http://newsourcemedia.com/blog/php-validation-numbers-only-from/
Thanks a lot mate, very nice solution
thanks mate! looking for this
Exactly what i was looking for to sort out an absolutely massive list with each item duplicated. wrote a quick script, popped everything into an array and then just showed the even numbered entries. Half an hour of tedious deleting became five minutes of work. Thanks!!
nice. Thanks for sharing