droxlzcgnr639823 2013-06-19 09:14
浏览 35
已采纳

在PHP中乘以十进制数

From my database I get a decimal like, 25.30.

In PHP I multiply the decimal like this, 25.30 * 6. The result is 151,8 but with a comma.

The problem is that the result gets me a comma instead of a point like 151.8.

Is there a solution to solve this and get the result with a point?

  • 写回答

2条回答 默认 最新

  • dream_high1026 2013-06-19 09:19
    关注

    You want to format your number. From the manual:

    string number_format ( float $number , int $decimals = 0 , string $dec_point = '.' , string $thousands_sep = ',' )
    

    So for example in your case this would be:

    print number_format($number, 1, '.', ',');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?