ok have phone numbers stored in table as:
"0008675309"
i wouldn't want display that, i'd want format when call as:
(000)867-5309
would better store in database delimiter such / - or . can split later? or possible split number of characters?
here 1 liner want:
$phone = preg_replace('^(\d{3})(\d{3})(\d{4})$', '($1)$2-$3', $phone);
as added bonus won't change format if input format doesn't match (international numbers).
Comments
Post a Comment