Skip to content

Instantly share code, notes, and snippets.

@rlandas
Last active January 6, 2016 03:36
Show Gist options
  • Save rlandas/635f1275c46dfd2fc361 to your computer and use it in GitHub Desktop.
Save rlandas/635f1275c46dfd2fc361 to your computer and use it in GitHub Desktop.
REGEX: only contains integers
// only contains integers
if(ctype_digit((string) $string)){
// only contains integers
}
// 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