function phoneToNum($input){
if(is_int($input) == true){
return $input;
}
if($input == null){
$phoneNum = " ";
return $phoneNum;
}
else if(is_numeric($input)){
if(substr($input,0,2) == "02") { // 앞자리가 두자리일때-서울시 지역번호밖에 없다.
$phoneNum = substr($input,0,2)."-".substr($input,2,-4)."-".substr($input,-4);
}
else { // 앞자리 세자리일때
$phoneNum = substr($input,0,3)."-".substr($input,3,-4)."-".substr($input,-4);
}
return $phoneNum;
}
else return $input;
}
'Dev > PHP' 카테고리의 다른 글
| date 함수 인수 정리 (0) | 2013.05.23 |
|---|---|
| File System (0) | 2013.05.22 |
| 함수 정리 (0) | 2013.04.26 |
| <? 으로 시작하면 안되는 이유 (0) | 2013.04.19 |
| PHP 페이지 이동의 방법 (0) | 2013.04.19 |