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. Link to comment https://forums.phpfreaks.com/topic/80775-solved-way-to-check-if-a-variable-is-odd-or-even/ 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"; } Link to comment https://forums.phpfreaks.com/topic/80775-solved-way-to-check-if-a-variable-is-odd-or-even/#findComment-409692 Share on other sites More sharing options...
Sebolains Posted December 8, 2007 Author Share Posted December 8, 2007 thanks Link to comment https://forums.phpfreaks.com/topic/80775-solved-way-to-check-if-a-variable-is-odd-or-even/#findComment-409701 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.