Created
April 26, 2016 07:26
-
-
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
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
<?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