2
votes

In an international web app, we deal with currencies like this:

USD: 2,400.55 EUR: 2.400,55

I need to be able to print those number as 2400.55 (for usd) and 2400,55 (for EUR) The problem is that I don't know in advance what kind of currency is coming at me.

No matter what the number format is, I'd like to use a function that only strips out the thousand separator, no matter if that is a , or a .

The number_format didn't solve my issue as far as I could see. Any tips on this?

1
How is the application supposed to change the money value if you don't give it the input currency? - Shoe
Don't you gonna say that these numbers being stored in the 2,400.55 format, do you? - Your Common Sense

1 Answers

3
votes

Take a look at money_format function for that.

Note:

The LC_MONETARY category of the locale settings, affects the behavior of this function. Use setlocale() to set to the appropriate default locale before using this function.