. PHP offers two convenient functions to format (and print) Currency: money_format() and number_format() . The first can be used in conjunction with setlocale() to set the format type according to their own country, for example:
1 2 3 4 | 1234.56 ; $ Number = 1234.56; LC_MONETARY , 'en_US' ) ; setlocale (LC_MONETARY, 'en_US'); ( '%i' , $number ) ; echo money_format ('% s', $ number); / / 1,234.56 USD |
For us Europeans, and Italians, we can use:
1 2 3 4 | 1234.56 ; $ Number = 1234.56; LC_MONETARY , 'it_IT' ) ; setlocale (LC_MONETARY, 'en_US'); ( '%.2n' , $number ) ; echo money_format ('% .2 n', $ number); / / EUR 1234.56 |
However, in the simplest cases, and if it bothers EUR , you can use:
1 2 3 | 1234.56 ; $ Number = 1234.56; ( $number , 2 , ',' , '.' ) echo number_format ($ number, 2, ',', '.') / / 1234.56 |











Damn I had never seen money_format for php! thanks for the tip!