Skip to content

Instantly share code, notes, and snippets.

@phpfiddle
Created August 1, 2017 01:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phpfiddle/5988c8f50649d90c6cfbd1b75fc715cf to your computer and use it in GitHub Desktop.
Save phpfiddle/5988c8f50649d90c6cfbd1b75fc715cf to your computer and use it in GitHub Desktop.
[ Posted by Schand ] isDecimal vs is_float
<?php
function isDecimal($value) {
return ((float) $value !== floor($value));
}
$test_vars = array("10","1.01", "1.0101");
foreach ($test_vars as $var) {
echo $var . "is_float: " . is_float($var) . " | isDecimal:" . isDecimal($var) . "<br>";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment