Capturing with nested parentheses
<? if (preg_match('/^(\d{5})(-(\d{4}))?$/',$_POST['zip'],$matches)) { print "The beginning of the ZIP Code is: $matches[1]\n"; if (isset($matches[2])) { print "The ZIP+4 is: $matches[3]"; } } ?>