Created
May 27, 2016 20:18
-
-
Save mathamoz/6a8b638532d2b3663e216e6f1ffff1f1 to your computer and use it in GitHub Desktop.
Find if a string is a double or an integer
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 integerOrDouble($val) { | |
if (is_numeric($val) && strpos($val, '.')) { | |
return 'double'; | |
} else if (is_numeric($val)) { | |
return 'integer'; | |
} | |
return NULL; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment