For the purposes of readability and reusability. PHP may try to make these coding staples as awkward as possible, but at least we've still got the good old function available to us. :)
Printable View
For the purposes of readability and reusability. PHP may try to make these coding staples as awkward as possible, but at least we've still got the good old function available to us. :)
Heres a tested function to check all US zipcodes:
PHP Code:<?php
function validate_zip($zipcode){
return preg_match('/^[0-9]{5}([- ]?[0-9]{4})?$/', $zipcode);
}
?>