Sebolains Posted December 8, 2007 Share Posted December 8, 2007 Hi. I was wondering if there is a function, or a simple way to do an IF to check wether a variable is odd or even. Ex.: If ($num is even) { lalalala } . Is there a way? Thanks for everyone. Quote Link to comment Share on other sites More sharing options...
Henaro Posted December 8, 2007 Share Posted December 8, 2007 $n = 2; if($n%2 == 0){ echo "even"; }else{ echo "odd"; } Quote Link to comment Share on other sites More sharing options...
Sebolains Posted December 8, 2007 Author Share Posted December 8, 2007 thanks 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.