# I was bored last night when Alpha. Z converted numbers into Chinese classes.

Source: Internet
Author: User
Tags ereg
Some unnecessary zero SyntaxHighlighter. all (); Information & nbsp; | & nbsp; Security & nbsp; | & nbsp; Forum & nbs

Removed some unnecessary zeros. "Zero", "one", "two", "three", "four", "five", "six", "seven", "eight ", "9"); // var \$ basical = array (0 => "zero", "one", "two", "three", "si", "Wu ", "Lu", "Lu"); var \$ advanced = array (1 => "10", "hundreds", "thousands "); // var \$ advanced = array (1 => "pick up", "success", "success"); var \$ top = array (1 => "ten thousand ", "999999999999"); var \$ level; // level-1 with 4 bits // implement the function ParseNumber (\$ number) {if (\$ number>) in case of a number transformation) // It can only process hundreds of billions of logs. Return "the number is too large to be processed. Sorry! "; If (\$ number = 0) return" zero "; for (\$ this-> level = 0; \$ number> 0.0001; \$ this-> level ++, \$ number = floor (\$ number/10000) {// For Chinese, it should be a group of four digits. // The four variables correspond to digits, and digits. \$ N1 = substr (\$ number,-1, 1); if (\$ number> 9) \$ n2 = substr (\$ number,-2, 1); else \$ n2 = 0; if (\$ number> 99) \$ n3 = substr (\$ number,-999); else \$ n3 = 0; if (\$ number>) \$ n4 = substr (\$ number, -4,1); else \$ n4 = 0; if (\$ n4) \$ parsed [\$ this-> level]. = \$ this-> basical [\$ n4]. \$ this-> advanced [3]; else if (\$ number/10000)> = 1) // The kilobytes are 0, if the value is greater than 9999, \$ parsed [\$ this-> level]. = "zero"; if (\$ n3) \$ parsed [\$ this-> level]. = \$ this-> basical [\$ n3]. \$ this-> advanced [2 ]; Else if (! Ereg ("Zero \$", \$ parsed [\$ this-> level]) & (\$ number/1000)> = 1) // if two consecutive "zeros" are not displayed, \$ parsed [\$ this-> level]. = "zero"; if (\$ n2) \$ parsed [\$ this-> level]. = \$ this-> basical [\$ n2]. \$ this-> advanced [1]; else if (! Ereg ("Zero \$", \$ parsed [\$ this-> level]) & (\$ number/100)> = 1) // if two consecutive "zeros" are not displayed, \$ parsed [\$ this-> level]. = "zero"; if (\$ n1) \$ parsed [\$ this-> level]. = \$ this-> basical [\$ n1]; if (\$ parsed [\$ this-> level]! = "Zero") {if (ereg ("Zero \$", \$ parsed [\$ this-> level]) \$ parsed [\$ this-> level] = substr (\$ parsed [\$ this-> level], 0, strlen (\$ parsed [\$ this-> level])-2 ); if (\$ this-> level> 0) \$ result = \$ parsed [\$ this-> level]. \$ this-> top [\$ this-> level]. \$ result; else \$ result = \$ parsed [\$ this-> level]. \$ result; }}// for (\$ this-> level-= 1; \$ this-> level> = 0; \$ this-> level --) // {// \$ result. = \$ parsed [\$ this-> level]. \$ this-> top [\$ this-> level]; //} // if (ereg ("Zero \$", \$ Result) // \$ result = substr (\$ result, 0, strlen (\$ result)-2); return \$ result ;}; \$ c = new ChineseNumber (); echo \$ c-> ParseNumber (100000000001);?>

Related Keywords:

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.