- // Chinese_money.PHP
- // Changing Arab Money Num to Chinese Money Num
- /*
-
- Functions List:
-
- Chinese_Money_Max ()
- Before Decimal point
- This function can be used to convert an Arabic number into a Chinese number separately (case-sensitive). The default value is uppercase)
- Only integers (positive and negative)
-
- Chinese_Money_Min ()
- After Decimal point processing
-
- Chinese_Money ()
- By bbs.it-home.org
- */
-
- Function Chinese_Money_Max ($ I, $ s = 1 ){
- $ C_digIT_min = array ("0", "10", "", "MB ");
- $ C_num_min = array ("zero", "one", "two", "three", "four", "five", "six", "seven ", "8", "9", "10 ");
-
- $ C_digIT_max = array ("0", "pick up", "success", "success", "", "megabytes ");
- $ C_num_max = array ("zero", "one", "two", "three", "si", "Wu", "Lu", "Lu ", "Pick", "pick ");
-
- If ($ s = 1 ){
- $ C_digIT = $ c_digIT_max;
- $ C_num = $ c_num_max;
- } Else {
- $ C_digIT = $ c_digIT_min;
- $ C_num = $ c_num_min;
- }
-
- If ($ I <0)
- Return "negative". Chinese_Money_Max (-$ I );
- // Return "-". Chinese_Money_Max (-$ I );
- If ($ I <11)
- Return $ c_num [$ I];
- If ($ I <20)
- Return $ c_num [1]. $ c_digIT [1]. $ c_num [$ I-10];
- If ($ I <100 ){
- If ($ I % 10)
- Return $ c_num [$ I/10]. $ c_digIT [1]. $ c_num [$ I % 10];
- Else
- Return $ c_num [$ I/10]. $ c_digIT [1];
- }
- If ($ I <1000 ){
- If ($ I % 100 = 0)
- Return $ c_num [$ I/100]. $ c_digIT [2];
- Else if ($ I % 100 <10)
- Return $ c_num [$ I/100]. $ c_digIT [2]. $ c_num [0]. Chinese_Money_Max ($ I % 100 );
- Else if ($ I % 100 <10)
- Return $ c_num [$ I/100]. $ c_digIT [2]. $ c_num [1]. Chinese_Money_Max ($ I % 100 );
- Else
- Return $ c_num [$ I/100]. $ c_digIT [2]. Chinese_Money_Max ($ I % 100 );
- }
- If ($ I <10000 ){
- If ($ I % 1000 = 0)
- Return $ c_num [$ I/1000]. $ c_digIT [3];
- Else if ($ I % 1000 <100)
- Return $ c_num [$ I/1000]. $ c_digIT [3]. $ c_num [0]. Chinese_Money_Max ($ I % 1000 );
- Else
- Return $ c_num [$ I/1000]. $ c_digIT [3]. Chinese_Money_Max ($ I % 1000 );
- }
- If ($ I <100000000 ){
- If ($ I % 10000 = 0)
- Return Chinese_Money_Max ($ I/10000). $ c_digIT [4];
- Else if ($ I % 10000 <1000)
- Return Chinese_Money_Max ($ I/10000). $ c_digIT [4]. $ c_num [0]. Chinese_Money_Max ($ I % 10000 );
- Else
- Return Chinese_Money_Max ($ I/10000). $ c_digIT [4]. Chinese_Money_Max ($ I % 10000 );
- }
- If ($ I <1000000000000 ){
- If ($ I % 100000000 = 0)
- Return Chinese_Money_Max ($ I/100000000). $ c_digIT [5];
- Else if ($ I % 100000000 <1000000)
- Return Chinese_Money_Max ($ I/100000000). $ c_digIT [5]. $ c_num [0]. Chinese_Money_Max ($ I % 100000000 );
- Else
- Return Chinese_Money_Max ($ I/100000000). $ c_digIT [5]. Chinese_Money_Max ($ I % 100000000 );
- }
- If ($ I % 1000000000000 = 0)
- Return Chinese_Money_Max ($ I/1000000000000). $ c_digIT [6];
- Else if ($ I % 1000000000000 <100000000)
- Return Chinese_Money_Max ($ I/1000000000000). $ c_digIT [6]. $ c_num [0]. Chinese_Money_Max ($ I % 1000000000000 );
- Else
- Return Chinese_Money_Max ($ I/1000000000000). $ c_digIT [6]. Chinese_Money_Max ($ I % 1000000000000 );
- }
-
- Function Chinese_Money_Min ($ ){
- $ C_num = array ("zero", "one", "two", "three", "four", "five", "six", "seven ", "8", "9", "10 ");
- If ($ a <10)
- Return $ c_num [0]. "". $ c_num [$ a]. "points ";
- Else if ($ a % 10 = 0)
- Return $ c_num [$ a/10]. "". $ c_num [0]. "points ";
- Else
- Return $ c_num [floor ($ a/10)]. "". $ c_num [$ a % 10]. "points ";
- }
- /* Two digits after the decimal point */
- Function Chinese_Num_Min ($ ){
- $ C_num = array ("zero", "one", "two", "three", "four", "five", "six", "seven ", "8", "9", "10 ");
- If ($ a <10)
- Return $ c_num [0]. $ c_num [$ a];
- Else if ($ a % 10 = 0)
- Return $ c_num [$ a/10]. $ c_num [0];
- Else
- Return $ c_num [floor ($ a/10)]. $ c_num [$ a % 10];
- }
-
-
- Function Chinese_Money ($ I ){
- $ J = Floor ($ I );
- $ X = ($ I-$ j) * 100;
- // Return $ x;
- // Return Chinese_Money_Max ($ j). "yuan". Chinese_Money_Min ($ x). "whole ";
- Return Chinese_Money_Max ($ j, '0'). "point". Chinese_Num_Min ($ x );
- }
-
- // The Following Code is Testing The Functions:
- /*
- $ E_money = 332123.32;
- Echo Chinese_Money ($ e_money );
- */
- ?>
|