我正在寻找一种方法将数字字符串(如主题中所示)转换为合适的字符串,如$ 40,000,000。
php是否提供了执行此操作的功能?
感谢您的帮助!
答案 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);