I'm doing some calculations and I end up with 65.0
or 43.5
.
I need to add a zero to this number so that my number comparison works:
$this->sub_total == $order_sub_total
I've tested using number_format():
$total = number_format($total, 2, '.');
But that gives me er msg: Wrong parameter count for number_format()
I'm tempted to just do:
$total = $total.'0';
But I think that is a bad idea in case the number is 35.43
.
So how can I add a extra decimal to my number?
With number_format()
you need either two or four parameters. Three will always through an error.
For you both of the following will work identically:
$total = number_format($total, 2);
$total = number_format($total, 2, '.', ',');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With