Question about integers (php) -
possible duplicate:
php: shortest way check if variable contains positive integer?
how know, given variable number without residue (and not negative number)?
like have numbers (each number variable): 5; 6.416; -76; 254.
its better have function, give true or false, like:
number "5" true 6.416 false (has residue "416") -76 false 254 true.
thanks.
this should it:
function is_positive_int($n) { return $n && abs(intval($n)) == $n; }
Comments
Post a Comment