-
-
- //chinese_money.PHP
- //Changing Arab Money Num to Chinese Money Num
- /*
-
- Functions List:
-
- Chinese_Money_Max()
- Before the decimal point
- This function can be used separately Convert Arabic numerals to Chinese numerals (uppercase and lowercase are optional, default is uppercase)
- Only integers (both positive and negative)
-
- Chinese_Money_Min()
- Process after decimal point
-
- Chinese_Money()
- by bbs.it-home.org
- */
-
- function Chinese_Money_Max($i,$s=1){
- $c_digIT_min = array("zero","ten","hundred","thousand","ten thousand","billion","trillion" );
- $c_num_min = array("zero","one","two","three","four","five","six","seven","eight","nine","ten ");
-
- $c_digIT_max = array("zero","hundred","hundred","qian","ten thousand","billion","trillion");
- $c_num_max = array("zero"," "一","二","三","四","五","鲁","撒","八","九","十");
-
- 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 / 10000 0000) .$c_digIT [5] . Chinese_Money_Max($i % 100000000);
- }
- if ($i % 1000000000000 == 0)
- return Chinese_Money_Max($i / 1000000000000) . $c_digIT[6];
- else if ($i % 100 0000000000< ; 100000000)
- return Chinese_Money_Max($i / 1000000000000) . $c_digIT[6] . $c_num[0] . Chinese_Money_Max($i % 1000000000000);
- else
- return_Money_Max($i / Chinese 100000000 0000) . $c_digIT[6] . Chinese_Money_Max($i % 1000000000000);
- }
-
- function Chinese_Money_Min($a){
- $c_num = array("zero","one","two","three","four","five", "six","seven","eight","nine","ten");
- if($a<10)
- return $c_num[0] . "angle" . $c_num[$a] . "points ";
- else if($a%10 == 0)
- return $c_num[$a/10] . "angle" . $c_num[0] . "point";
- else
- return $c_num[floor($a /10)] . "angle" . $c_num[$a%10] ."cent";
- }
- /*Two decimal places*/
- function Chinese_Num_Min($a){
- $c_num = array("zero","one","two","three","four","five","six" ,"seven","eight","nine","ten");
- 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)." ".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);
- */
- ?>
Copy code
|