RE: [PHP] Is it odd or even???
| From: | Boget, Chris | Date: | Mon, 05 Mar 2001 20:42:51 +0000 |
| Subject: | RE: [PHP] Is it odd or even??? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-42670@lists.php.net to get a copy of this message | ||
> Color me confused because I though true was any non zero
> value and false was zero.
Right. And
if( $num % 2 ) {
echo "it's odd";
}
means that the operation returned a remainder - a non zero value.
> 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
And this is:
If( NOT ZERO ) {
Odd
}
which is the same as:
if( $num % 2 ) {
If there is a remainder, it's not zero.
Chris