【发布时间】:2012-08-03 11:54:13
【问题描述】:
我正在做一些计算,最终得到65.0 或43.5。
我需要在这个数字上加一个零,以便我的数字比较有效:
$this->sub_total == $order_sub_total
我已经使用 number_format() 进行了测试:
$total = number_format($total, 2, '.');
但这给了我消息:Wrong parameter count for number_format()
我很想这样做:
$total = $total.'0';
但如果号码是35.43,我认为这是个坏主意。
那么我怎样才能给我的数字添加一个额外的小数呢?
【问题讨论】:
-
如果你提到小数分隔符,你也必须使用千位分隔符。
-
@matt 谢谢,我不知道。我已经阅读了文档,但并不总是那么容易理解:)
-
@Dale 一些地区使用
,作为小数分隔符,因此number_format($total, 2)并非普遍正确。为了确保 OP 得到他想要的结果,他必须使用number_format($total, 2, '.', ',');。
标签: php number-formatting