Code for converting uppercase amounts to lowercase amounts in PHP (accurate to minute) _php tutorial

Source: Internet
Author: User
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 ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.