寻求能将数字转换成英文的PHP程序?

致版主:能提供一下将数字转换成英语的小程序吗?
http://fxstudio.51.net/others/useful/php/num2word.php
-----------------------------------------
上面这个程序能将数字转换成英语,如:
您输入的数字为6546513134546416转换成英文后结果是:Six Quadrillion, Five Hundred Forty-Six Trillion, Five Hundred Thirteen Billion, One Hundred Thirty-Four Million, Five Hundred Forty-Six Thousand, Four Hundred Sixteen
谁能提供这样的代码,高分相送!

---------------------------------------------------------------

给个思路吧:
先将该数字3个一组分开,然后再判断
用一个函数
geten($num,$location)
其中$num是最大三位的数,$location是第几个三位数(从右向左)
比如geten(6,1)=>six thousand
geten(16,1)=>sixteen thousand
然后你再写个函数,将3位数字转换成为英文表示。
因为英文数字的单位是以3位数为基的,比如千、百万、十亿...
2位数的大至是这样的:20以内有单独的表示,大于20就有规律可循了。应该不会太难。
---------------------------------------------------------------

"Thousand",2=>"Million",3=>"Billion",4=>"Trillion",5=>"Quadrillion",6=>"Quintillion",7=>"Sextillion",8=>"Septillion",9=>"Octillion",10=>"Nonillion",11=>"Decillion",12=>"Undecillion",13=>"Duodecillion",14=>"Tredecillion",15=>"Septemdecillion",16=>"Octodecillion",17=>"Novemdecillion",18=>"Vigintillion"); function getnum($temp){ $个位级=array(1=>"One",2=>"Two",3=>"Three",4=>"Four",5=>"Five",6=>"Six",7=>"Seven",8=>"Eight",9=>"Nine",10=>"Ten"); $十位数=array(11=>"Eleven",12=>"Twelve",13=>"Thirteen",14=>"Fourteen",15=>"Fiftenn",16=>"Sixteen",17=>"Seventeen",18=>"Eighteen",19=>"Nineteen"); $十位级=array(2=>"Twenty",3=>"Thirty",4=>"Forty",5=>"Fifty",6=>"Sixty",7=>"Seventy",8=>"Eighty",9=>"Ninety"); if($temp<100){ $百=0; $十=$temp; }else{ $百=floor($temp/100); $十=$temp%100; } if($百<>0){ $result=$个位级[$百]." Hundred"; } if($十<11){ $result.=" ".$个位级[$十]; }elseif($十<20){ $result.=" ".$十位数[$十]; }else{ if($十%10==0) $result.=" ".$十位级[$十/10]; else $result.=" ".$十位级[floor($十/10)]."-".$个位级[$十%10]; } return $result; } echo ' ```
'; echo ''; echo ''; echo '
``` '; if($submit){ $numtmp=$num; for($i=0;$i ``` =0;$i--){ $结果.=getnum($arr[$i])." ".$数量级[$i]." "; } echo $结果; } ?> ```
Published At
Categories with Web编程
comments powered by Disqus