You could use a regular expression and see if you match a - and if you don't then you can format the results using eregi_replace() or use substr(). Use strlen() to check the length also and make sure that it isn't longer than x digits so that when you add the dash at keypoints you end up with the right format. Below the code is a little lengthy, untested, and could be tightened but is one possible way to accomplish what you want. Let's assume a phone number we want in the following format: