Search code examples
phpmoney-format

Writing the good format of a currency in PHP


When we write an invoice, we have to respect the money format

For example :

  • in France, you will write 1000,00 €

  • In the USA, $ 1,000.00

I would like to know if it is handled by some PHP library ? especially the money symbol at the left or right.

Edit :

I have never been downvoted like this and i think my question wasn't that well asked. Sorry for that.

I already know different formatting functions in PHP and I understand that the formatter options should be selected for each country and their money format. Thou, i don't have the time to do that job.

My objective is to format any money values for all possible locales in the world without registering all those locales.

Maybe somebody wrote a class which can do the job but I didn't find it.

Btw I know it is difficult, I can for example talk of the example of the EUR.

In many contry they write EUR xxxxx. In some countries, it is written xxxx EUR.


Solution

  • Yep, by the intl module.

    For currencies there is a NumberFormater class:

    http://www.php.net/manual/en/numberformatter.formatcurrency.php