Get the App
SLTechnology News&Howtos  ›  Development  › 

How does php format phone numbers

Shulou Source: shulou.com Published: 2022-06-03 19:44:24 11月12日 Update

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.

Tags: Phone article number format phone number more good practical content function article knowledge China USA analysis reference help related Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Docker Shulou Information Linux Apple