清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
// 阿拉伯数字转中文大写金额 function NumToCNMoney($num,$mode = true,$sim = true){ if(!is_numeric($num)) return '含有非数字非小数点字符!'; $char = $sim ? array('零','一','二','三','四','五','六','七','八','九') : array('零','壹','贰','叁','肆','伍','陆','柒','捌','玖'); $unit = $sim ? array('','十','百','千','','万','亿','兆') : array('','拾','佰','仟','','萬','億','兆'); $retval = $mode ? '元':'点'; //小数部分 if(strpos($num, '.')){ list($num,$dec) = explode('.', $num); $dec = strval(round($dec,2)); if($mode){ $retval .= "{$char[$dec['0']]}角{$char[$dec['1']]}分"; }else{ for($i = 0,$c = strlen($dec);$i < $c;$i++) { $retval .= $char[$dec[$i]]; } } } //整数部分 $str = $mode ? strrev(intval($num)) : strrev($num); for($i = 0,$c = strlen($str);$i < $c;$i++) { $out[$i] = $char[$str[$i]]; if($mode){ $out[$i] .= $str[$i] != '0'? $unit[$i%4] : ''; if($i>1 and $str[$i]+$str[$i-1] == 0){ $out[$i] = ''; } if($i%4 == 0){ $out[$i] .= $unit[4+floor($i/4)]; } } } $retval = join('',array_reverse($out)) . $retval; return $retval; } echo (NumToCNMoney(2.55)."<br>"); echo (NumToCNMoney(2.55,1,0)."<br>"); echo (NumToCNMoney(7965)."<br>"); echo (NumToCNMoney(7965,1,0)."<br>"); echo (NumToCNMoney(155555555.68)."<br>"); echo (NumToCNMoney(155555555.68,1,0)."<br>"); echo (NumToCNMoney(0.8888888)."<br>"); echo (NumToCNMoney(0.8888888,1,0)."<br>"); echo (NumToCNMoney(99999999999)."<br>"); echo (NumToCNMoney(99999999999,1,0)."<br>");