Skip to content

Commit 6699f4e

Browse files
committed
phone format
1 parent 6b21670 commit 6699f4e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Util.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -793,10 +793,10 @@ public static function unzip($zip_file, $extract_path = null) {
793793
} return false;
794794
}
795795

796-
public static function formatPhone($input, $country_code = 1) {
796+
public static function formatPhone($input, $country_code = 1, $format = '+%1$s (%2$s) %3$s-%4$s') {
797797
$clean_input = substr(preg_replace('/\D+/i', '', $input), -10);
798798
if (preg_match('/^(\d{3})(\d{3})(\d{4})$/', $clean_input, $matches)) {
799-
$result = '+'.$country_code.' ('.$matches[1].') '.$matches[2].'-'.$matches[3];
799+
$result = sprintf($format, $country_code, $matches[1], $matches[2], $matches[3]);
800800
return $result;
801801
}
802802

0 commit comments

Comments
 (0)