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

Jef*_*eff 3 php

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

php提供了这样做的功能吗?

谢谢您的帮助!

Orb*_*bit 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);    
Run Code Online (Sandbox Code Playgroud)