Re: If value is odd or not

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Steven Osborn wrote:
$odd = array("1","3","5","7","9");

if(inarray(substr($var,strlen($var)-1,1),$od)
{
  //haha
}
else
{
  //even
}



How about this

if ($var % 2 == 0) { //it's even
} else { //it's odd
}
--
Online library -- http://pueblonative.110mb.com
126 books and counting.

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux