숫자를 한글로
Server Side/PHP2023. 12. 1. 22:55
function number2hangul($number){
$num = array('', '일', '이', '삼', '사', '오', '육', '칠', '팔', '구');
$unit4 = array('', '만', '억', '조', '경');
$unit1 = array('', '십', '백', '천');
$res = array();
$number = str_replace(',','',$number);
$split4 = str_split(strrev((string)$number),4);
for($i=0;$i<count($split4);$i++){
$temp = array();
$split1 = str_split((string)$split4[$i], 1);
for($j=0;$j<count($split1);$j++){
$u = (int)$split1[$j];
if($u > 0) $temp[] = $num[$u].$unit1[$j];
}
if(count($temp) > 0) $res[] = implode('', array_reverse($temp)).$unit4[$i];
}
return implode('', array_reverse($res));
}
echo number2hangul("46701");
'Server Side > PHP' 카테고리의 다른 글
PHP 해킹 안당하려면 php.ini disable_functions 수정 (0) | 2023.12.16 |
---|---|
php 세션 class (0) | 2023.12.11 |
cURL header 에 API Key 실어 보내기 (0) | 2023.11.12 |
[CodeIgniter] URL 규칙과 URI 가져오기 (0) | 2023.10.29 |
Geolocation으로 현재 위치 구하기 (PHP) (0) | 2023.10.02 |