PHP money_format,带有货币符号

问题描述

| 如何使用其货币符号将数字格式化为正确的位置?仅允许最终用户通过输入来确定其货币符号会更好吗?     

解决方法

你可以用
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
    

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...