Ste*_*ven 4 php number-formatting
我正在做一些计算,最后我65.0还是43.5.
我需要在这个数字上加零,以便我的数字比较有效:
$this->sub_total == $order_sub_total
我已经使用number_format()进行了测试:
$total = number_format($total, 2, '.');
Run Code Online (Sandbox Code Playgroud)
但这给了我一些消息: Wrong parameter count for number_format()
我很想做:
$total = $total.'0';
Run Code Online (Sandbox Code Playgroud)
但我认为这个数字是个坏主意35.43.
那么如何为我的号码添加额外的小数?
Joh*_*nde 17
有了number_format()你需要两个或四个参数.三个将永远通过一个错误.
对于您来说,以下两个都将完全相同:
$total = number_format($total, 2);
$total = number_format($total, 2, '.', ',');
Run Code Online (Sandbox Code Playgroud)