Frank Vilea
Frank Vilea

Reputation: 8487

How to output abbreviated currency symbol instead of currency name when using money_format()?

Is there a flag in the money_format function that lets you replace the long currency (e.g. USD, EUR) with the abbreviated version ($, €)?

Upvotes: 4

Views: 2917

Answers (1)

Footle
Footle

Reputation: 66

Yes: the documentation specifies the "n" flag for the current locale's national currency format:

<?php
setlocale(LC_MONETARY, 'en_GB.UTF-8');
echo money_format('%n', 7.99); // £7.99

setlocale(LC_MONETARY, 'en_US.UTF-8');
echo money_format('%n', 7.99); // $7.99

Make sure you set a locale for LC_MONETARY (or LC_ALL, of course).

Upvotes: 5

Related Questions