note 23182 added to function.floor
| From: | php-general at lists dot php dot net | Date: | Thu, 11 Jul 2002 08:38:52 +0000 |
| Subject: | note 23182 added to function.floor | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-32885@lists.php.net to get a copy of this message | ||
> The sample to show "odd" or "even" doesn't work
> like that. Use this:
Actually, the best (and most elegant) way to check if a number is odd or even is to use the modulus
operator:
if ($number%2 == 0) {
// Even
} else {
// Odd
}
--
http://www.php.net/manual/en/function.floor.php
http://master.php.net/manage/user-notes.php?action=edit+23182
http://master.php.net/manage/user-notes.php?action=delete+23182
http://master.php.net/manage/user-notes.php?action=reject+23182