日期:2011-04-13  浏览次数:20487 次


<?
//chinese_money.php
//Changing Arab Money Num to Chinese Money Num
/*======================

Functions List:

Chinese_Money_Max()
小数点前
此函数可以单独拿出用于将阿拉伯数字转为中文数字(大小写可选,默认为大写)
仅限整数(正负皆可)

Chinese_Money_Min()
处理小数点后

Chinese_Money()

=======================*/


function Chinese_Money_Max($i,$s=1){
    $c_digit_min = array("零","十","百","千","万","亿","兆");
    $c_num_min = array("零","一","二","三","四","五","六","七","八","九","十");
    
    $c_digit_max = array("零","拾","佰","仟","万","亿","兆");
    $c_num_max = array("零","壹","贰","叁","肆","伍","陆","柒","捌","玖","拾");
    
    if($s==1){
        $c_digit = $c_digit_max;
        $c_num = $c_num_max;
    }
    else{
        $c_digit = $c_digit_min;
        $c_num = $c_num_min;
    }
    
    if($i<0)
        return "负".Chinese_Money_Max(-$i);
    if ($i < 11)
        return $c_num[$i];
    if ($i < 20)
        return $c_num[1].$c_digit[1] . $c_num[$i - 10];
    if ($i < 100) {
        if ($i % 10)
            return $c_num[$i / 10] . $c_digit[1] . $c_num[$i % 10];
        else
            return $c_num[$i / 10] . $c_digit[1];
    }
    if ($i < 1000) {
        if ($i % 100 == 0)
            return $c_num[$i / 100] . $c_digit[2];
        else if ($i % 100 < 10)
            return $c_num[$i / 100] . $c_digit[2] . $c_num[0] . Chinese_Money_Max($i % 100);
        else if ($i % 100 < 10)
            return $c_num[$i / 100] . $c_digit[2] . $c_num[1] . Chinese_Money_Max($i % 100);
        else
            return $c_num[$i / 100] . $c_digit[2] . Chinese_Money_Max($i % 100);
    }
    if ($i < 10000) {
        if ($i % 1000 == 0)
            return $c_num[$i / 1000] . $c_digit[3];
        else if ($i % 1000 < 100)
       &nbs