<?php
function callCenterNumber(int $type): string
{
$call_center_phone_number = "+998 (78) 777 1515"; //"+998 (78) 777 1515"
if ($type === 1) {
$temp = str_replace(" ", "", $call_center); // убрать пробелы: "+998 (78) 777 1515" -> "+998(78)7771515"
$temp1 = str_replace("+", "", $temp); // убрать плюс: "+998(78)7771515" -> "998(78)7771515"
$temp2 = substr_replace($temp1, "78", 3, 4); // убрать скобки: "998(78)7771515" -> "998787771515"
$temp3 = substr($temp2, 3); // убрать код: "998787771515" -> "787771515"
$call_center_phone_number = $temp3; // 787771515
}
if ($type === 2) {
$temp = substr($call_center, 5); // asdasd: "+998 (78) 777 1515" -> "(78) 777 1515"
$temp1 = substr_replace($temp, " ", 11, 0); // убрать плюс: "(78) 777 1515" -> "(78) 777 15 15"
$call_center_phone_number = $temp1; // (78) 777 15 15
}
if ($type === 3) {
$temp = substr($call_center, 5); // asdasd: "+998 (78) 777 1515" -> "(78) 777 1515"
$temp1 = substr_replace($temp, "-", 11, 0); // убрать плюс: "(78) 777 1515" -> "(78) 777 15-15"
$temp2 = substr_replace($temp1, "-", 8, 1); // убрать плюс: "(78) 777 15-15" -> "(78) 777-15-15"
$call_center_phone_number = $temp2; // (78) 777-15-15
}
if ($type === 4) {
$temp = str_replace(["(", ")"], "", $call_center); // убрать пробелы: "+998 (78) 777 1515" -> "+998 78 777 1515"
$call_center_phone_number = $temp; // +998 78 777 1515
}
return $call_center_phone_number;
}
var_dump(callCenterNumber(2));