@@ -20,11 +20,13 @@ |
||
20 | 20 | */ |
21 | 21 | public static function format($phone) |
22 | 22 | { |
23 | - if (preg_match('/^(\d{1})(\d{3})(\d{3})(\d{2})(\d{2})$/', $phone, $matches)) |
|
24 | - return "+" . $matches[1] . ' (' . $matches[2] . ') ' . $matches[3] . "-" . $matches[4] . '-' . $matches[5]; |
|
23 | + if (preg_match('/^(\d{1})(\d{3})(\d{3})(\d{2})(\d{2})$/', $phone, $matches)) { |
|
24 | + return "+" . $matches[1] . ' (' . $matches[2] . ') ' . $matches[3] . "-" . $matches[4] . '-' . $matches[5]; |
|
25 | + } |
|
25 | 26 | |
26 | - if (preg_match('/^(\d{2})(\d{3})(\d{3})(\d{2})(\d{2})$/', $phone, $matches)) |
|
27 | - return "+" . $matches[1] . ' (' . $matches[2] . ') ' . $matches[3] . "-" . $matches[4] . '-' . $matches[5]; |
|
27 | + if (preg_match('/^(\d{2})(\d{3})(\d{3})(\d{2})(\d{2})$/', $phone, $matches)) { |
|
28 | + return "+" . $matches[1] . ' (' . $matches[2] . ') ' . $matches[3] . "-" . $matches[4] . '-' . $matches[5]; |
|
29 | + } |
|
28 | 30 | |
29 | 31 | return $phone; |
30 | 32 | } |