Posted By

tasmanweb on 04/28/11


Tagged

php function


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

wirenaught


is_odd


 / Published in: PHP
 

returns TRUE if the given number is odd else FALSE. remember: if a number is not odd then that doesn't automatically mean it is even (fractions, negative numbers). even = number / 2 = 0. odd = number / 2 = 1.

  1. function is_odd($num){
  2. return (($num - (2 * floor($num/2))) == 1);
  3. }

Report this snippet  

You need to login to post a comment.