实现目的:

对数字进行格式化,以类似¥10,000,000的格式输出。

实现方法:

function doFormatMoney($money){
    $tmp_money = strrev($money);
    $format_money = "¥"; 
    for($i = 3;$i<strlen($money);$i+=3){
        $format_money .= substr($tmp_money,0,3).",";
         $tmp_money = substr($tmp_money,3);
     }
    $format_money .=$tmp_money;
    $format_money = strrev($format_money); 
    return $format_money;
}

相关文章:

  • 2022-12-23
  • 2021-05-25
  • 2021-08-31
  • 2021-11-28
  • 2022-12-23
  • 2021-07-23
猜你喜欢
  • 2021-08-03
  • 2021-12-02
  • 2022-12-23
  • 2021-07-01
  • 2021-09-22
  • 2022-12-23
相关资源
相似解决方案