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. Quote Link to comment 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> Quote Link to comment Share on other sites More sharing options...
phpSensei Posted January 21, 2008 Author Share Posted January 21, 2008 Thanks man. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.