----- Original Message ----- 
From: "joel boonstra" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, January 16, 2004 3:35 PM
Subject: Re: [PHP] odd and even numbers


> On Fri, Jan 16, 2004 at 02:30:59PM -0600, Jeremy wrote:
> > function isOdd ($value) {
> > return (int)$value % 2 ? true : false;
> > }
> >
> > Returns true/false if the value is odd. Also rounds down floating point
numbers given as the test value.
>
> No need to explicitly state "true" and "false".  Just negate the result
> of your modulus operator, and take advantage of the fact that "0" is
> false, and "1" is true:
>
> function isOdd ($value) {
>   return !((int)$value % 2);
> }
>
> -- 
> [ joel boonstra | gospelcom.net ]
>
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>








Thanks everyone for the fast replys!

Jake

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

Reply via email to