This commit is contained in:
41
app/Helpers/string_helper.php
Normal file
41
app/Helpers/string_helper.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
if (!function_exists('sqlstr_quotes')) {
|
||||
function sqlstr_quotes($str)
|
||||
{
|
||||
return str_replace("'", "''", $str);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('phone_format')) {
|
||||
function phone_format($str)
|
||||
{
|
||||
|
||||
$phone = $str;
|
||||
if (substr($phone, 0, 2) == '02') {
|
||||
switch (strlen(($phone))) {
|
||||
case 9:
|
||||
$phone = substr($phone, 0, 2) . '-' . substr($phone, 2, 3) . '-' . substr($phone, 5, 4);
|
||||
break;
|
||||
|
||||
case 10:
|
||||
$phone = substr($phone, 0, 2) . '-' . substr($phone, 2, 4) . '-' . substr($phone, 6, 4);
|
||||
break;
|
||||
|
||||
}
|
||||
} else {
|
||||
switch (strlen(($phone))) {
|
||||
case 10:
|
||||
$phone = substr($phone, 0, 3) . '-' . substr($phone, 3, 3) . '-' . substr($phone, 6, 4);
|
||||
break;
|
||||
case 11:
|
||||
$phone = substr($phone, 0, 3) . '-' . substr($phone, 3, 4) . '-' . substr($phone, 7, 4);
|
||||
break;
|
||||
case 12:
|
||||
$phone = substr($phone, 0, 4) . '-' . substr($phone, 4, 4) . '-' . substr($phone, 8, 4);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $phone;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user