[原]阿拉伯数字金额转中文大写函数(2 位领导批示)
- 2009-04-3
- 分类:PHP&MySql
- 作者:银子
- 866 位领导视察
最近正好用到.就自己写了个.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | function chinese_money($money) { $str = array('零','壹','贰','叁','肆','伍','陆','柒','捌','玖'); $unit = array('零','分','角','元','拾','佰','仟','万','拾','佰','仟','亿','拾','佰','仟'); $money = str_replace(",","",$money); $money = number_format($money,2); $money = str_replace(".","",$money); $money = str_replace(",","",$money); $f = $money; $money = abs($money); if($f != $money) $m = '负'; $len = strlen($money); for ($i=1; $i<=$len; $i++) { $num = substr($money,$i-1,1); $j = strlen($money)+1-$i; $m .= $num . $unit[$j]; } foreach($str as $key=>$val) { $m = str_replace($key,$val,$m); } return $m; } $money = 9123123.12; echo $money . "\n"; echo chinese_money($money); |
















