开发者

php: format currency without thousand separator

开发者 https://www.devze.com 2023-02-08 12:23 出处:网络
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)

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 cu开发者_高级运维rrency 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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号