phpSensei Posted January 20, 2008 Share Posted January 20, 2008 I am very terrible in regex, and yes i did skip that one chapter when learning php. I would like to know the best way of validating a zip code. Help is appreciate it. Link to comment https://forums.phpfreaks.com/topic/86933-solved-zip-codes/ Share on other sites More sharing options...
effigy Posted January 21, 2008 Share Posted January 21, 2008 <pre> <?php echo preg_match('/\A\d{5}(?:-\d{4})?\z/', '12345') ? 'Matched' : 'Did not match' ; ?> </pre> Link to comment https://forums.phpfreaks.com/topic/86933-solved-zip-codes/#findComment-445175 Share on other sites More sharing options...
phpSensei Posted January 21, 2008 Author Share Posted January 21, 2008 Thanks man. Link to comment https://forums.phpfreaks.com/topic/86933-solved-zip-codes/#findComment-445577 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.