- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
public function format_phone($phone) {
$phone = preg_replace("/\D/", "", $phone);
$first_digit = substr($phone, 0, 1);
if ($first_digit == "7" || $first_digit == "8") {
$phone = substr($phone, 1);
}
if ($first_digit == "+") {
$phone = substr($phone, 2);
}
$p = str_split($phone);
$phone = "(" . $p[0] . $p[1] . $p[2] . ") " . $p[3] . $p[4] . $p[5] . "-" . $p[6] . $p[7] . "-" . $p[8] . $p[9];
return $phone;
}
odoviez 18.05.2016 08:12 # −1
6a6yuH 24.08.2021 21:46 # 0