【问题标题】:money_format, move the 'currency name'money_format,移动“货币名称”
【发布时间】:2012-03-12 12:38:32
【问题描述】:

我目前正在使用PHP money_format() function,并且现在有money_format('%.0i', $row['price']),它输出如下内容:DKK 199.900 - 有没有办法像 一样输出它>199.900 DKK

【问题讨论】:

  • 只需阅读money_format 上的文档:php.net/manual/de/function.money-format.php 那里详细解释了如何准确解决您的问题。
  • 巴斯蒂,抱歉找不到。
  • 我的错。我看到问题是money_format 将在数字之前输出DKK,即使在da_DK 语言环境中也是如此。我看不到您可以告诉money_format 将货币符号放在不同的位置。我会使用 number_format 并像 Ing 一样手动添加货币符号。您是否需要根据区域设置更改货币符号,还是始终为 DKK?
  • 至少现在永远是丹麦克朗!

标签: php currency money-format


【解决方案1】:

改用number_format(这也是跨操作系统兼容的):

$value = number_format($value, [decimal places]).' DKK';

【讨论】:

    【解决方案2】:

    将money_format的第一个参数替换为'%.0i DKK';

    【讨论】:

    • 但是,请考虑使用number_format,因为money_format 存在兼容性问题。
    • money_format('%.0i DKK', $number) 将输出string 'DKK 1.235 DKK' (length=13)setlocale(LC_MONETARY, "da_DK");
    【解决方案3】:

    所以money_format('%!.0i DKK', $price); 模式可能是! 将推迟自动货币符号并在最后手动添加的解决方案

    【讨论】:

      【解决方案4】:

      其实@sandeep 是对的,他只是忘了加上! 来去掉开头的货币符号。

      setlocale(LC_MONETARY, 'da_DK');
      $money_in_the_bank = 9333;
      echo money_format('%!.0i DKK', $money_in_the_bank);
      

      这将输出:

      9.333 DKK

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-03-06
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多