[原]阿拉伯数字金额转中文大写函数(2 位领导批示)

最近正好用到.就自己写了个.

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);

随机显示的10篇日志

评论最多的10篇日志

浏览最多的10篇日志