用PHP将数字转换为字母 [英] Convert number to letter with php
本文介绍了用PHP将数字转换为字母的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Possible Duplicate:
Converting a number (1, 2, 3) to a string (one, two, three) in PHP
我正在编写发票脚本.我正在寻找将数字转换为字母的php脚本. 例如,发票显示此值:155€
I'm programming an invoice script. I'm looking for a php script that convert number to letter. Exemple, the invoice show this value : 155€
脚本自动放置:一百五十五
The script put automatically: ONE HUNDRED FIFTY FIVE
有什么想法吗?
谢谢:)
推荐答案
尝试查看 NumberFormatter (适用于PHP).
Try looking into NumberFormatter for PHP.
示例脚本:
<?php
$f = new NumberFormatter("en", NumberFormatter::SPELLOUT);
echo $f->format(123456);
?>
产生结果:
one hundred twenty-three thousand four hundred fifty-six
这篇关于用PHP将数字转换为字母的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文