Arabic digital turn Chinese big (small) write function

xiaoxiao2021-03-06  97

Arabic digital turn Chinese big (small) write function

Erquan published on 2002-7-10 17:43 PHP programming

//chinese_money.php

// Changing arab Money Num to Chinese Money Num

/ * =======================

Functions List:

Chinese_money_max ()

Decimal point

This function can be used separately to convert the Arabic number to Chinese (case of selective, default is uppercase)

Only integers (all right)

Chinese_money_min ()

After processing the decimal point

Chinese_money ()

=============================== * /

Function CHINESE_MONEY_MAX ($ I, $ S = 1) {

$ c_digit_min = array ("zero", "ten", "hundred", "thousand", "10 million", "mega");

$ c_num_min = array ("zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten");

$ c_digit_max = array ("zero", "", "", "10 million", "mega");

$ c_num_max = array ("zero", "", "", "", "", "Wu", "柒", "捌", "", "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);

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% 10000000000);

Else

RETURN CHINESE_MONEY_MAX ($ I / 1000000000000). $ 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]. "分"; ELSE IF ($ A% 10 == 0)

RETURN $ C_NUM [$ A / 10]. "Corner". $ c_num [0]. "points";

Else

Return $ C_NUM [Floor ($ A / 10)]. "Corner". $ c_num [$ a% 10]. "points";

}

Function Chinese_money ($ i) {

$ j = floor ($ i);

$ x = ($ I- $ J) * 100;

// Return $ x;

RETURN CHINESE_MONEY_MAX ($ J). "Yuan" .CHINESE_MONEY_MIN ($ x). "whole";

}

// The folowing code is testing the functions:

/ *

IF ($ _ submit == 'go')

Echo chinese_money ($ E_MONEY);

echo "

";

echo "";

echo "";

Echo "";

* /

?>

转载请注明原文地址:https://www.9cbs.com/read-102083.html

New Post(0)