开发者

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

开发者 https://www.devze.com 2023-03-18 17:40 出处:网络
开发者_StackOverflowIs 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\"
开发者_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

精彩评论

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