Tandem Posted October 15, 2006 Share Posted October 15, 2006 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? Quote Link to comment Share on other sites More sharing options...
AndyB Posted October 15, 2006 Share Posted October 15, 2006 modulus operator - http://ca.php.net/operators.arithmetic[code]<?php$num = 4; // exampleif ($num%2) { echo "odd";} else { echo "even";}?>[/code] Quote Link to comment Share on other sites More sharing options...
Tandem Posted October 15, 2006 Author Share Posted October 15, 2006 Thanks, i'll give this a try. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.