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);?>