时间:2021-07-01 10:21:17 帮助过:15人阅读
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).(isset($units[($l-1)%$ul])?$units[($l-1)%$ul]:'');
//之前为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;
}
functioncny($ns) {static$cnums=array("零","壹","贰","叁","肆","伍","陆","柒","捌","玖"),
$cnyunits=array("圆","角","分"),
$grees=array("拾","佰","仟","万","拾","佰","仟","亿");
list($ns1,$ns2)=explode(".",$ns,2);
$ns2=str_split($ns2);//此处为新增if(isset($ns2[1]))
$ns2=array_filter(array($ns2[1],$ns2[0]));
else$ns2=array_filter(array($ns2[0]));
//之前为$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)));
$out=str_replace(array_keys($cnums),$cnums,$ret);
if($ns==round($ns))$out.="整";
return$out;
}
目前不再报错了,貌似逻辑对了。
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i <= lines; i++) { $numbering.append($('').text(i)); }; $numbering.fadeIn(1700); }); });以上就介绍了关于php数字转大写人民币的代码完善),包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。