t

전화번호에 하이픈 넣기

register_form_update.php, orderformupdate.php 파일에서 사용할 수 있습니다.

사용법은 아래와 같습니다.
$mb_tel = hyphen_tel_number($mb_tel);
$od_tel = hyphen_tel_number($od_tel);
$od_b_tel = hyphen_tel_number($od_b_tel);

common.lib.php 파일에 넣어주세요.

// 전화번호의 숫자만 취한 후 중간에 하이픈(-)을 넣는다.
// 전화번호의 숫자만 취한 후 중간에 하이픈(-)을 넣는다.
function hyphen_tel_number($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);
}
|

댓글 4개

고맙습니다.
자바스크립트면 더좋을텐데 말이죠 감사합니다.
감사합니다~
감사합니다~
댓글을 작성하시려면 로그인이 필요합니다.
+
제목 글쓴이 날짜 조회
14-05-14 조회 8,512
14-05-13 조회 1.5만
14-05-13 조회 3만
14-05-12 조회 1.3만
14-05-11 조회 1.4만
14-05-09 조회 1.4만
14-05-09 조회 1.9만
14-05-07 조회 1.1만
14-05-07 조회 1.5만
14-05-03 조회 9,784
14-04-28 조회 1.2만
14-04-27 조회 8,408
14-04-27 조회 1.1만
14-04-19 조회 9,128
14-04-14 조회 8,736
14-04-13 조회 9,479
14-04-13 조회 1.5만
14-04-11 조회 1.8만
14-04-10 조회 9,405
14-04-09 조회 1.5만
14-03-29 조회 1.9만
14-03-28 조회 1만
14-03-25 조회 1.2만
14-03-24 조회 2만
14-03-15 조회 1.3만
14-03-14 조회 1.2만
14-03-13 조회 1.3만
14-03-13 조회 1만
14-03-12 조회 1.1만
14-03-10 조회 1만