How to convert, for example, "40 million" in 40 million dollars?

I am looking for a way to hide a numeric string (as shown in the topic) to a suitable one, for example, $ 40,000,000.

Does php offer a function for this?

Thanks for the help!

+3
source share
1 answer
$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);    
+9
source

Source: https://habr.com/ru/post/1796541/


All Articles