Link to home
Start Free TrialLog in
Avatar of sypder
sypder

asked on

Format phone number in PHP

Users submit their phone number as part of a form. With PHP I would like to take an reasonable phone number format and convert it to:

9998887777

I think of some exceptable number formats as:

1-222-333-4444
222-333-444
222333444
(222)333-4444
(222) 333-4444
222 333-4444
1(222) 333-4444
etc...

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of Esopo
Esopo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sypder
sypder

ASKER

Thanks. That will work well. The one other thing I need to do is remove a leading 1, if it exists? I have not yet read my regexp book. That is going to be my reading on my flight tonight.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sypder

ASKER

Wow, that is obvious and simple. For some reason I was thinking complicated.
Are you aware that you didn't give me any points?
Avatar of sypder

ASKER

I am so sorry! I (wrongfully) assumed that the two posts were both by you. I know see they were not. How can I assign points after the fact?
You can request assistance at Community Support:
https://www.experts-exchange.com/Community_Support/