sugan Posted November 20, 2007 Share Posted November 20, 2007 Hi,If i enter the phone number as 9843067889 it should change into (984) 306-7899.How to do this in php? Regards,Sugan Link to comment Share on other sites More sharing options...
Synook Posted November 20, 2007 Share Posted November 20, 2007 You can split the number up and insert the new characters - this regex should do the trick $phone = "9843067889";$phone = preg_replace("/([0-9]{3})([0-9]{3})([0-9]{4})/", "($1) $2-$3", $phone); Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.