Color me confused because I though true was any non zero value and false was
zero.

I know I am using the following code:

if (!($num % 4){ do something}

and it does something when $num is evenly divisible by 4 (ie. $num % 4 = 0).

If I were testing for odd vs even I'd do the following:

if (!($num % 2) {
Odd
} else {
Even
}

John Guynn

This email brought to you by RFCs 821 and 1225.


-----Original Message-----
From: Boget, Chris [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 05, 2001 2:33 PM
To: 'Kenneth R Zink II'; Php (E-mail)
Subject: RE: [PHP] Is it odd or even???


> That won't work.  % returns the remainder from a division of 
> the number divided by the mod number.

Yours:

> if($num %2 == 0){
> echo "even";
> }else{
> echo "odd";
> }

Mine:

> > if( $num % 2 ) {
> >   echo "Odd";
> >
> > } else {
> >   echo "Even";
> >
> > }

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to