Php format the phone number. Php formatting of phone numbers this article describes how php formatting of phone numbers. Share it with you for your reference. The specific analysis is as follows: the php formatting method of the phone number
Php phone number formatting method
This example describes how to format the phone number in php. Share it with you for your reference. The specific analysis is as follows:
This function is only applicable to American phones. you need to modify Chinese phones.
?
1 2 3 4 5 6 7 8 9 10 |
Function format_phone ($ phone) { $ Phone = preg_replace ("/[^ 0-9]/", "", $ phone ); If (strlen ($ phone) = 7) Return preg_replace ("/([0-9] {3}) ([0-9] {4})/", "$1-$2", $ phone ); Elseif (strlen ($ phone) = 10) Return preg_replace ("/([0-9] {3}) ([0-9] {3}) ([0-9] {4 })/", "($1) $2-$3", $ phone ); Else Return $ phone; } |
I hope this article will help you with php programming.
Using php to format a phone number. This document describes how to format a php phone number. Share it with you for your reference. The specific analysis is as follows...