Created
March 12, 2013 09:12
-
-
Save jeremejazz/5141396 to your computer and use it in GitHub Desktop.
Snippet for checking if string is an integer or 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 | |
$number = '3.8'; | |
if ((int) $number == $number) { | |
//it is an integer | |
}else{ | |
//it is a float | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment