问题描述
|
如何使用其货币符号将数字格式化为正确的位置?仅允许最终用户通过输入来确定其货币符号会更好吗?
解决方法
你可以用
LC_MONETARY
$number = 1234.56;
// let\'s print the international format for the en_US locale
setlocale(LC_MONETARY,\'en_US\');
echo money_format(\'%i\',$number) . \"\\n\";
// USD 1,234.56
// Italian national format with 2 decimals`
setlocale(LC_MONETARY,\'it_IT\');
echo money_format(\'%.2n\',$number) . \"\\n\";
// Eu 1.234,56