开发者

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

开发者_StackOverflow

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


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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜