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? Link to comment https://forums.phpfreaks.com/topic/24021-even-number-detecting/ 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] Link to comment https://forums.phpfreaks.com/topic/24021-even-number-detecting/#findComment-109145 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. Link to comment https://forums.phpfreaks.com/topic/24021-even-number-detecting/#findComment-109146 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.