如何转换例如“40,000”到40,000,000美元?

时间:2011-03-05 20:28:55

标签: php

我正在寻找一种方法将数字字符串(如主题中所示)转换为合适的字符串,如$ 40,000,000。

php是否提供了执行此操作的功能?

感谢您的帮助!

1 个答案:

答案 0 :(得分:9)

$str = str_replace(' billion','000000000',$str);
$str = str_replace(' million','000000',$str);
$str = str_replace(' thousand','000',$str);
$str = str_replace(' hundred','00'$str);

setlocale(LC_MONETARY, 'en_US');    
$str = money_format('%i',$str);