I have this PHP code:
$entityElementCount = (-($highScore-$totalKeywordCount))/0.29;
What i want to know is, how to check whether $
I know this is a super old post but this is a simple function that will return a valid whole number and cast it to an int. Returns false if it fails.
function isWholeNumber($v)
{
if ($v !='' && is_numeric($v) && strpos($v, '.') === false) {
return (int)$v;
}
return false;
}
Usage :
$a = 43;
$b = 4.3;
$c = 'four_three';
isWholeNumber($a) // 43
isWholeNumber($b) // false
isWholeNumber($c) // false