Search code examples
phpnumberformatter

PHP NumberFormatter inverting commas and decimals


I'm using PHP's number formatter on a local server and while it does work, it's printing out US dollar amounts like this: 8.500,00 $ when I actually want it to look like this: $8,500.00. Is there some parameter within the function that'll allow me to fix this problem or do I have to use something else?


Solution

  • It looks like you have the wrong locale set in your NumberFormatter object. The format $8,500.00 is the USA's format. Make sure you've told NumberFormatter to use the correct locale.