Date Added: 17/01/2017

PHP preg_replace formating telephone number   (999) 123 4567 

$tel_numbers = explode("\n", '(111) 222-3333

((111) 222-3333
0901112223333
111 222-3333
111-222-3333
test(111)2223333
+11234567890
1-8002353551
123-456-7890 -Hello test!
+1 - 1234567890
');

foreach($tel_numbers as $tel_number){
print preg_replace('~.*(\d{3})[^\d]{0,7}(\d{3})[^\d]{0,7}(\d{4}).*~', '($1) $2-$3', $tel_number). "<br>";
}

Last Update: Posted by: müslüm ÇEN

Not Commented Yet !
Please login in order to comment . Login