Created
August 1, 2017 01:37
-
-
Save phpfiddle/5988c8f50649d90c6cfbd1b75fc715cf to your computer and use it in GitHub Desktop.
[ Posted by Schand ] isDecimal vs is_float
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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