Create string.utl.php

This commit is contained in:
Namhyeon Go 2018-05-16 03:19:27 +09:00 committed by GitHub
parent e83e3d32aa
commit 02463519b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

15
helper/string.utl.php Normal file
View File

@ -0,0 +1,15 @@
<?php
function add_hyphen($tel) {
$tel = preg_replace("/[^0-9]/", "", $tel); // 숫자 이외 제거
if (substr($tel,0,2)=='02')
return preg_replace("/([0-9]{2})([0-9]{3,4})([0-9]{4})$/", "\\1-\\2-\\3", $tel);
else if (strlen($tel)=='8' && (substr($tel,0,2)=='15' || substr($tel,0,2)=='16' || substr($tel,0,2)=='18'))
// 지능망 번호이면
return preg_replace("/([0-9]{4})([0-9]{4})$/", "\\1-\\2", $tel);
else
return preg_replace("/([0-9]{3})([0-9]{3,4})([0-9]{4})$/", "\\1-\\2-\\3", $tel);
}
function br2nl($string) {
return preg_replace('/\<br(\s*)?\/?\>/i', "\n", $string);
}