數(shù)字轉(zhuǎn)英文
更新時間:2006年12月06日 00:00:00 作者:
<?php //___{xf_num2en}________________________________________
//*** 說明: 數(shù)值轉(zhuǎn)英文表示法
//=== 回傳: <string>
//--- NN)數(shù)值 FF)小數(shù)位
//============================================================
function xf_num2en($NN, $FF=0) {
//===[前置]========================================
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=>"fifty",
60=>"sixty",70=>"seventy",80=>"eighty",90=>"ninety");
//===[整數(shù)]========================================
$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. 'million '. $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
//===[小數(shù)]========================================
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 ?>
//*** 說明: 數(shù)值轉(zhuǎn)英文表示法
//=== 回傳: <string>
//--- NN)數(shù)值 FF)小數(shù)位
//============================================================
function xf_num2en($NN, $FF=0) {
//===[前置]========================================
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=>"fifty",
60=>"sixty",70=>"seventy",80=>"eighty",90=>"ninety");
//===[整數(shù)]========================================
$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. 'million '. $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
//===[小數(shù)]========================================
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 ?>
相關(guān)文章
PHP在線生成二維碼(google api)的實現(xiàn)代碼詳解
本篇文章是對PHP在線生成二維碼(google api)的實現(xiàn)代碼進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-06-06關(guān)于DISCUZ不用通行證登陸得內(nèi)容介紹
DISCUZ是中國最常用的論壇,雖然他本身有通行證給大家連接,但實際上用戶的統(tǒng)一還是很不好,經(jīng)常要建立兩個用戶表,第一不利于注冊和管理,第二浪費數(shù)據(jù)庫。2008-10-10將PHP的session數(shù)據(jù)存儲到數(shù)據(jù)庫中的代碼實例
這里我們將分享兩個將PHP的session數(shù)據(jù)存儲到數(shù)據(jù)庫中的代碼實例,分別針對PostgreSQL與MySQL,需要的朋友可以參考下2016-06-06php 偽造HTTP_REFERER頁面URL來源的三種方法
這篇文章主要介紹了php 偽造HTTP_REFERER頁面URL來源的三種方法的相關(guān)資料,需要的朋友可以參考下2016-09-09Ajax實時驗證用戶名/郵箱等是否已經(jīng)存在的代碼打包
一個網(wǎng)站采用Ajax技術(shù),不僅可以改善網(wǎng)站的用戶體驗性,而且大大節(jié)約了寶貴的帶寬,減輕了服務(wù)器負(fù)荷(不再需要交互整個網(wǎng)頁內(nèi)容,而是局部)。2011-12-12