金額の換算に使用したい場合は小数部の処理を修正する必要があります
function ch_num($num,$mode=true) {
$char = array( "ゼロ", "一", "二", "三", "四", "五", "呂", "旒", "八", "玖"); dw = array(" ","十","百","千","","万","十億","兆"); = "";
if($mode)
preg_match_all("/^0*(d*).?(d*)/",$num, $ar); 🎜>preg_match_all(" /(d*).?(d*)/",$num, $ar);
if($ar[2][0] != "")
$retval = $dec .ch_num($ar[2][0],false); //小数がある場合は、最初に小数を再帰的に処理します
if($ar[1][0] != "") {
$str = strrev($ar[1][0]);
for($i=0;$i
if($mode) {
$out[$i] .= $str[$i] != "0"? %4] : "";
if($str[$i] $str[$i-1] == 0)
$out[$i] == ""; i%4 == 0)
$out[$i] .= $dw[4 Floor($i/4)]
}
}
$retval = join("", array_reverse($out)) . $ retval;
}
return $retval;
//echo ch_num("12345006789001.123"); 880079.1234");
echo ch_num("300045.0123");
?>