How does php format phone numbers
This article will explain in detail how to format phone numbers in php. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
The specific analysis is as follows:
This function is only applicable to American phones. Chinese phones need to be modified by themselves.
Function format_phone ($phone) {$phone = preg_replace ("/ [^ 0-9] /", ", $phone); if (strlen ($phone) = = 7) return preg_replace (" / ([0-9] {3}) ([0-9] {4}) / "," $1 Mustang 2 ", $phone) Elseif (strlen ($phone) = = 10) return preg_replace ("/ ([0-9] {3}) ([0-9] {3}) ([0-9] {4}) /", "($1) $2Muth3", $phone); else return $phone } this is the end of the article on "how to format phone numbers in php". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.