Last active
January 21, 2020 08:55
-
-
Save jefferyrdavis/5992282 to your computer and use it in GitHub Desktop.
Snippit: PHP: Simple US Zip Code format validation
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 | |
/* Validates if $zipCode is a 5 digit number in the 12345 format. Note that this simply checks to see if $zipCode is a 5 digit number, not necessarily a valid U.S. Zip Code. | |
*/ | |
function validateZipCode($zipCode) { | |
if (preg_match('#[0-9]{5}#', $zipCode)) | |
return true; | |
else | |
return false; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
what bout to add empty zipcode