Return to Snippet

Revision: 7004
at July 1, 2008 09:36 by aristoworks

Initial Code
$string = "12345-1234";
if (preg_match('/^[0-9]{5}([- ]?[0-9]{4})?$/', $string)) { 
echo "zip code checks out";

Initial URL

Initial Description
This is a simple method of validating a 9-digit zip code using PHP and regular expressions

Initial Title
PHP (RegEx) Zip Code Validation

Initial Tags
php, code, validation

Initial Language