Copy CodeThe code is as follows:
/**
* A function of converting a digital amount into a Chinese capital amount
*string Int $num lowercase number or lowercase string to convert
*return Capital Letters
* Decimal place is two digits
**/
function Get_amount ($num) {
$c 1 = "0 One and three Woolu qi Ba Jiu";
$c 2 = "split-angle element pick Bai thousand thousand million";
$num = Round ($num, 2);
$num = $num * 100;
if (strlen ($num) > 10) {
Return "The data is too long, there is no such big money, check under";
}
$i = 0;
$c = "";
while (1) {
if ($i = = 0) {
$n = substr ($num, strlen ($num)-1, 1);
} else {
$n = $num% 10;
}
$p 1 = substr ($c 1, 3 * $n, 3);
$p 2 = substr ($c 2, 3 * $i, 3);
if ($n! = ' 0 ' | | ($n = = ' 0 ' && ($p 2 = = ' billion ' | | $p 2 = = ' million ' | | $p 2 = = ' Yuan '))) {
$c = $p 1. $p 2. $c;
} else {
$c = $p 1. $c;
}
$i = $i + 1;
$num = $num/10;
$num = (int) $num;
if ($num = = 0) {
Break
}
}
$j = 0;
$slen = strlen ($c);
while ($j < $slen) {
$m = substr ($c, $j, 6);
if ($m = = ' 0 Yuan ' | | $m = = ' 0 ' | | $m = = ' 0 ' | | $m = = ' 00 ') {
$left = substr ($c, 0, $j);
$right = substr ($c, $j + 3);
$c = $left. $right;
$j = $j-3;
$slen = $slen-3;
}
$j = $j + 3;
}
if (substr ($c, strlen ($c)-3, 3) = = ' 0 ') {
$c = substr ($c, 0, strlen ($c)-3);
}
if (empty ($c)) {
Return "0 yuan whole";
}else{
Return $c. "Whole";
}
}
http://www.bkjia.com/PHPjc/324762.html www.bkjia.com true http://www.bkjia.com/PHPjc/324762.html techarticle Copy the code as follows:/** * A function of converting a digital amount to a Chinese capital amount *string Int $num the lowercase number or lowercase string to convert *return uppercase * Decimal place to two bits ...