【问题标题】:How to format number = "$lowprice" to currency如何将 number = "$lowprice" 格式化为货币
【发布时间】:2018-04-05 06:45:45
【问题描述】:

如何将 number = "$lowprice" 格式化为货币

$price_content .= '<span>';
if ($currency_sympol) $price_content .= get_post_meta($id,$wprs_prefix.'lowprice', TRUE);
$price_content .= '<sup>'.$currency_sympol.'</sup>';
$price_content .= '</span>';

【问题讨论】:

  • 请将代码格式化为代码而不是普通文本。

标签: php currency


【解决方案1】:

要将数字格式化为货币,请使用money_format() 函数。 (Docs)

$lowprice = 1234.56;

// Italian national format with 2 decimals
setlocale(LC_MONETARY, 'it_IT');
echo money_format('%.2n', $lowprice) . "\n";
// Eu 1.234,56

由于货币源自服务器区域设置,您可能需要更改它(参见示例)。

【讨论】:

  • 如果你发现答案解决了你的问题,请accept it
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-05-24
  • 1970-01-01
  • 2016-05-03
  • 2015-03-20
  • 2020-06-21
  • 1970-01-01
相关资源
最近更新 更多