Last active
January 6, 2016 03:36
-
-
Save rlandas/635f1275c46dfd2fc361 to your computer and use it in GitHub Desktop.
REGEX: only contains integers
This file contains hidden or 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
// only contains integers | |
if(ctype_digit((string) $string)){ | |
// only contains integers | |
} |
This file contains hidden or 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
// check if string only contains integers | |
if(preg_match('/^[0-9]+$/', (string) $string)){ | |
// only contains integers | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment