SyntaxFix
Write A Post
Hire A Developer
Questions
Try something like:
preg_replace('/\d{3}/', '$0-', str_replace('.', null, trim($number)), 2);
this would take a $number of 8881112222 and convert to 888-111-2222. Hope this helps.
8881112222
888-111-2222