Jump to content

Archived

This topic is now archived and is closed to further replies.

Tandem

even number detecting?

Recommended Posts

Hi, i need some way to be able to detect whether a number is even or not. I searched the php manual but couldn't find anything that does this.

Anyone know of a way to do this?

Share this post


Link to post
Share on other sites
modulus operator - http://ca.php.net/operators.arithmetic

[code]<?php
$num = 4; // example
if ($num%2) {
    echo "odd";
} else {
    echo "even";
}
?>[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.