Rotary

Links
Tech
  • PHP

People will enter phone numbers in all kinds of ways, but generally we want them to all display in the same way. I got tired of trying different approaches to this same problem, so I wrote this simple little library to normalize input and then render it out based or a simple template.

echo Render::pretty('1234567890');
// (123) 456-7890

echo Render::pretty('123 456 7890');
// (123) 456-7890

echo Render::pretty('[123) 456/7890');
// (123) 456-7890