Convert a numeric value (less than billion RMB) to an uppercase renminbi solution

Source: Internet
Author: User
Convert a value (less than billion RMB) to an upper-case RMB rt: convert a value (less than billion RMB) to an upper-case RMB. PHP is used for this purpose. PHPer quick AH, http://www.phparticipant le.net/htmldata/2268/1/,phpcode&lt ;? Error_reporting (2047); # report all invalid errors ob_star converts the value (below billion RMB) into uppercase RMB
Rt: converts a value (less than billion RMB) to an upper-case RMB. PHP is used for this purpose. PHPer fast

------ Solution --------------------
Http://www.phparticle.net/htmldata/2268/1/
------ Solution --------------------
PHP code
  Pow () return "The amount must be less than billion"; $ re = ''; $ arr1 = array ('0', 'yi', 'er', 'san ', 'ta', 'wu', 'Lu', 'region'); $ arr2 = array ('meta', 'pick ', 'Taobao', 'Taobao', 'wan', 'Taobao', 'Taobao', 'yie', 'Taobao', 'Taobao ', 'quantity'); $ arr3 = array ('angular ', 'quantity', 'pct', 'Milli '); $ pre1 = count ($ arr2 ); # precision in units $ pre2 = count ($ arr3); # precision in decimal places $ arr = @ explode (". ", $ RMB); # cut by decimal point $ len1 = @ strlen ($ arr [0]); # integer length $ len2 = @ strlen ($ arr [1]); # decimal scale length for ($ I = 0; $ I <$ len1 & $ I <$ pr E1; $ I ++) {$ bit = $ arr [0] [$ len1-$ i-1]; # Current lowercase amount $ cn = $ arr1 [$ bit]; # Current bit capital amount $ unit = $ arr2 [$ I]; # Current bit amount unit # case where the lowercase amount is zero if ($ bit = 0) {if (ereg ('RMB |', $ unit) $ re = $ unit. $ re; else $ re = $ cn. $ re ;}# else {$ re = $ cn. $ unit. $ re ;}}for ($ I = 0; $ I <count ($ arr3) & $ I <$ len2; $ I ++) {$ bit = $ arr [1] [$ I]; # The current lowercase amount $ cn = $ arr1 [$ bit]; # Current bit capital amount $ unit = $ arr3 [$ I]; # Current bit amount unit if ($ bit! = 0) $ re. = $ cn. $ unit; elseif ($ I <2) $ re. = "0";} if ($ Format) {# Format the lower-case amount # exact number of digits. Decimal places not less than 2, not greater than the maximum precision $ gage = min (max (2, $ len2), $ pre2); $ GLOBALS [$ Format] = number_format ($ RMB, $ gage ,". ",", ") ;}$ re = preg_replace (array ("//","/(0) $/","/(0) {2 ,} /"), array (" "," "," zero "), $ re); # replace the regular expression if (! $ Len2) $ re. = "integral"; # Add "integral" return $ re ;} /// // RMB ('20140901 '); $ money = isset ($ _ GET ['Money'])? $ _ GET ['Money']: ""; $ RMB = RMB ($ money, "money");?>

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.