Skip to content

Instantly share code, notes, and snippets.

@iolloyd
Created April 26, 2016 07:26
Show Gist options
  • Save iolloyd/e3e57f3cfbe48386d4bab43a34ee6ea1 to your computer and use it in GitHub Desktop.
Save iolloyd/e3e57f3cfbe48386d4bab43a34ee6ea1 to your computer and use it in GitHub Desktop.
an example of how to check for just letters without preg_match in php
<?php
function isValid($string) {
if (ctype_alpha($string)) {
return true;
} else {
return false;
}
}
// This returns true, just letters
var_dump(isValid("LloydMoore"));
// This returns false, because of the space
var_dump(isValid("Lloyd Moore"));
// This returns false
var_dump(isValid("Lloyd 2 Moore"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment