Search code examples
phpcurrency

php: format currency without thousand separator


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?


Solution

  • 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.