I've been fighting with the php money_format()
function for a while now and can't it to work exactly as I'd like it to.
I want the number to be formatted like this: €1.234,56
, and negative numbers - €1.234,56
.
I've already tried all possible combinations between the following:
Locales
- nl_NL
- en_US
- it_IT
- de_DE
Formats
€ +!-#3.2n
€ %-!4#8.2n
%-4#8.2n
None of them produce quite the right result. The most promising option right now is it_IT
with € %-!4#8.2n
, which produces all the required formatting except for the position of the -
sign, which is located behind the €
instead of in front of it.
Which format/locale combination do I need to use for this?
Thanks!
I would suggest you to better use the formatting options from the intl extension. Especially this one http://php.net/manual/en/numberformatter.formatcurrency.php
There you can set on each call which locale should be used, as well as they use a library for the correct format strings of the used locale