阿拉伯数字转中文数字
程序员文章站
2022-06-01 19:54:25
...
阿拉伯数字转中文数字
function ToChinaseNum($num)
{
$char = array("零","一","二","三","四","五","六","七","八","九");
$dw = array("","十","百","千","万","亿","兆");
$retval = "";
$proZero = false;
for($i = 0;$i
{
if($i > 0) $temp = (int)(($num % pow (10,$i+1)) / pow (10,$i));
else $temp = (int)($num % pow (10,1));
if($proZero == true && $temp == 0) continue;
if($temp == 0) $proZero = true;
else $proZero = false;
if($proZero)
{
if($retval == "") continue;
$retval = $char[$temp].$retval;
}
else $retval = $char[$temp].$dw[$i].$retval;
}
if($retval == "一十") $retval = "十";
return $retval;
}
AD:真正免费,域名+虚机+企业邮箱=0元