php将数字转化为中文大写人民币格式
2018-02-20 17:55
357 查看
error_reporting(0); function cny($ns) { static $cnums=array("零","壹","贰","叁","肆","伍","陆","柒","捌","玖"), $cnyunits=array("圆","角","分"), $grees=array("拾","佰","仟","万","拾","佰","仟","亿"); list($ns1,$ns2)=explode(".",$ns,2); $ns2=array_filter(array($ns2[1],$ns2[0])); $ret=array_merge($ns2,array(implode("",_cny_map_unit(str_split($ns1),$grees)),"")); $ret=implode("",array_reverse(_cny_map_unit($ret,$cnyunits))); return str_replace(array_keys($cnums),$cnums,$ret); } function _cny_map_unit($list,$units) { $ul=count($units); $xs=array(); foreach (array_reverse($list) as $x) { $l=count($xs); if ($x!="0" || !($l%4)) $n=($x=='0'?'':$x).($units[($l-1)%$ul]); else $n=is_numeric($xs[0][0])?$x:''; array_unshift($xs,$n); } return $xs; } echo cny('89746145848'); //捌佰玖拾柒亿肆仟陆佰壹拾肆万伍仟捌佰肆拾捌圆
相关文章推荐
- PHP将数字金额转化为中文人民币大写
- PHP将数字金额转化为中文人民币大写
- 人民币金额中数字格式转化为中文的人民币大写格式的全部代码
- PHP人民币金额数字转中文大写的函数代码
- 也发个PHP人民币金额数字转中文大写
- PHP人民币金额数字转中文大写
- PHP人民币金额数字转中文大写的函数
- php将金额数字转化为中文大写
- 将一串数字转化为中文字符串,使用 C# 将数字转换成大写人民币 (例如:用户输入2300,系统就会显示两千三百元 )
- PHP人民币金额数字转中文大写的函数代码
- 数字转化为人民币大写(PHP)
- PHP人民币金额数字转中文大写的函数
- php阿拉伯数字转中文人民币大写
- PHP人民币金额数字转中文大写的函数
- php阿拉伯数字转中文人民币大写
- 转化十亿以内的人民币数字为大写格式
- 数字转化为大写中文
- 数字变成大写的类,把人民币转化为大写汉字