php 处理数字为金钱格式

number_format(需要转换的数字,保留小数个数,小数点符号,每三位的分隔符)
echo number_format("1000000")."<br>"; //默认显示:1,000,000
echo number_format("1000000",2)."<br>";//默认显示:1,000,000.00
echo number_format("1000000",2,".",""); //自定义显示:1000000.00

还有一个money_format('')

但是这个函数没法在 Windows 平台上工作。

提示:该函数常与 setlocale() 函数一起使用。

<?php
  $num = 123456.78;
  setlocale(LC_MONETARY,"en_US");//en_US是国际模式 传NULL为China 可以自己尝试
  echo money_format("这个金额是%i", $number);
?>

输出结果是:

这个金额是USD 123,456.78
原文地址:https://www.cnblogs.com/pfdltutu/p/9018735.html