How to sepate every three decimals with intl?

I want to use php’s intl to format currency.
The code I wrote shows 20000.956 with USD currency code as below:
$ 20000.96
It is expected but I want to separate every 3 decimal digits with , like:
$ 20,000.96
How should I set attribute that it shows like that?

Use money_format()


Hi megazoid,
Thanks for trying to help but I am on windows server that doesn’t support this function!
I asked the same question on stackoverflow and got the same answer so I edited my question and said I am on windows and left comment on that answer that I edited the main question as I am on windows. He said you did “stealth edit”!!! He even had two fake accounts just to vote down others twice!!! Such impolite people are there on this garbage stackoverflow shit!!!

Are you sure that you’re using PHP? money_format() is a standard function. When you’re saving your script files what file extension do they have?

From the PHP manual:

The function money_format() is only defined if the system has strfmon capabilities. For example, Windows does not, so money_format() is undefined in Windows.

which of Intl’s method are you using? format() or formatCurrency()? the latter should do the grouping automatically. the former might work with NumberFormatter::TYPE_CURRENCY as 2nd parameter.

Does number_format work?

Thanks to all people who helped me for this question, I got it solved thanks.
sometimes I used stackoverflow and very seldom I got helped from nice people there and most often no useful answer, yesterday I even got insulted for the same question on stackoveflow, now I have difficulty to understand when a very nice and professional forums like SitePoint is here with polite moderators and helpful/nice people, why someone should consider to use stackoverflow that is actually just and extra and unnecessary site on the web and has no purposes of any kind except abuse and insult others. This is very odd why and how it became much popular! Who the f*** manage that stackoverflow shit and allow some jobless people to insult others?

The only question one must ask themselves in situations where server level packages are needed is whether the production server has the package or it can be installed. I highly doubt you’re working on a windows production server, right. You’re just referring to being able to install the package(s) on a local instance which is another problem completely. None the less, that problem is easily offset my running a Linux vm.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.