This question has already been answered:
- Phone number formatting 4 replies
Suppose there is a line with the number of the form 79167364857 . How can you bring it to the form, for example, +7 (916) 736-48-57 , but also to work not only for 916 , but for any code of regions of Russia? Maybe there are some regular solutions for PHP? Or regular season. Or is it still to "step" on the last character manually?
PS In all the above links, the answer is only for a code of 3 characters.