# Convert numbers to English _ php instances

Source: Internet
Author: User
Numbers to English // *** Description: English representation of data values
// === Response:
// --- NN) data value FF) small number
// ================================================ ======================================
Function xf_num2en (\$ NN, \$ FF = 0 ){
// === [Front-end] ========================================== ==========
If (! Is_numeric (\$ NN) return '';
(\$ FF> 2) and \$ FF = 2;
\$ Xn = ''; \$ xf = '';

Global \$ enws;
\$ Enws = array (
0 => "zero", 1 => "one", 2 => "two", 3 => "three", 4 => "four ",
5 => "five", 6 => "six", 7 => "seven", 8 => "eight", 9 => "nine ",
10 => "ten", 11 => "eleven", 12 => "twelve ",
13 => "thirteen", 14 => "fourteen", 15 => "fifteen ",
16 => "sixteen", 17 => "seventeen", 18 => "eighteen", 19 => "nineteen ",
20 => "twenty", 30 => "thirty", 40 => "forty", 50 => "ty ",
60 => "sixty", 70 => "seventy", 80 => "eighty", 90 => "ninety ");
// === [Integer] ==================================== ==========
\$ Nk = floor (\$ NN );
\$ Cnt = 0;
While (\$ nk ){
\$ N = \$ nk % 1000;
If (\$ n ){
\$ X = xf_enNum4 (\$ n );
If (\$ cnt = 1) \$ xn = \$ x. 'thousand'. \$ xn;
Elseif (\$ cnt = 2) \$ xn = \$ x. 'milon'. \$ xn;
Elseif (\$ cnt = 3) \$ xn = \$ x. 'billion'. \$ xn;
Elseif (\$ cnt = 4) \$ xn = \$ x. 'trillion'. \$ xn;
Else \$ xn = \$ x;
}
\$ Cnt + = 1;
\$ Nk = floor (\$ nk/1000 );
} // -- While
// === [Small data] ================================== ==========
If (\$ FF> 0 ){
\$ N = floor (\$ NN * 100) % 100;
(\$ N) and \$ xf = xf_enNum4 (\$ n). 'cent ';
}

Return \$ xn. \$ xf;
} // -- Xf_num2en

Function xf_enNum4 (\$ NN ){
Global \$ enws;
\$ Ans = '';
\$ N = floor (\$ NN/100 );
(\$ N) and \$ ans = \$ enws [\$ n]. 'hundred ';
\$ N = \$ NN % 100;
If (\$ n ){
If (\$ n <20) \$ ans. = \$ enws [\$ n]. '';
Else {
\$ M = floor (\$ n/10) * 10;
\$ Ans. = \$ enws [\$ m]. '';
\$ N = \$ n % 10;
(\$ N) and \$ ans. = \$ enws [\$ n]. '';
}
}
Return \$ ans;
} // -- Xf_enNum4?>
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.