A function of Arabic numerals to Chinese numerals, Arabic Chinese _php tutorial

Source: Internet
Author: User

A function of Arabic numerals to Chinese numerals, Arabic Chinese


Recently, because of the need, wrote a "Arabic numerals to Chinese numbers function." The search for the essence area saw a similar one.
I feel my algorithm is good, so paste it out to share if you want to use for the amount of conversion, the number of parts of the processing to do a change
function Ch_num ($num, $mode =true) {
$char = Array ("0", "one", "II", "three", "the", "WU", "Lu", "Qi", "ba", "JIU");
$DW = Array ("", "Pick", "Bai", "Thousand", "" "," Million "," Yi "," Mega ");
$dec = "dot";
$retval = "";
if ($mode)
Preg_match_all ("/^0* (\d*) \.?" (\d*)/", $num, $ar);
Else
Preg_match_all ("/(\d*) \.? (\d*)/", $num, $ar);
if ($ar [2][0]! = "")
$retval = $dec. Ch_num ($ar [2][0],false); If there are decimals, the decimal is first processed recursively
if ($ar [1][0]! = "") {
$str = Strrev ($ar [1][0]);
for ($i =0; $i
$out [$i] = $char [$STR [$i]];
if ($mode) {
$out [$i]. = $STR [$i]! = "0"? $DW [$i%4]: "";
if ($str [$i]+ $str [$i-1] = = 0)
$out [$i] = "";
if ($i%4 = = 0)
$out [$i]. = $DW [4+floor ($i/4)];
}
}
$retval = Join ("", Array_reverse ($out)). $retval;
}
return $retval;
}
Echo ch_num ("12345006789001.123");
Echo ch_num ("880079.1234");
Echo ch_num ("300045.0123");
?>

Detailed Description: http://php.662p.com/thread-364-1-1.html


Excel 2010 How to turn Arabic numerals into Chinese capital numbers? (no functions, no tools to convert directly)

Right-click the cell, select Format cells,
On the left of the Number tab, select Special, and on the right, select Chinese capital digits

In Excel, how to convert the numbers represented in Chinese to Arabic numerals??

Without this direct approach, you have to look at the rules of your data to decide what functions to use to help. Please give an example, detailed, if not, please pass the file to analyze.

http://www.bkjia.com/PHPjc/834764.html www.bkjia.com true http://www.bkjia.com/PHPjc/834764.html techarticle a function of Arabic numerals to Chinese numerals, Arabic Chinese has recently written a function of Arabic numerals to Chinese numerals. The search for the essence area saw a similar one. Sense ...

  • 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.