Two ways of doing this…be careful….
Best way ..
1 2 3 4 5 6 7 |
<?php $number = 123; $txt = sprintf("%1.2f",$number); echo $txt; ?> |
This now shows 123.00 (it has added two decimal places as zeros, to make up the number)
Second way …. (not as good, as it rounds up to 2 decimal places)
1 2 3 4 5 6 |
<?php $predicted = 23.1234; round($predicted, 2); ?> |
This will show 23.12 (and can be added to another number)
But…..if the answer was 123.00 it would show 123 (this is a problem, so use above way)
Third way…
1 2 3 4 5 6 |
<?php $predicted = 23.1234; $predicted = number_format($predicted, 2); ?> |
This will show 23.12 (but if it goes over 1000 will show a comma therefore not be able to add to another number)
Use both at once to be sure!
1 2 3 |
number_format(round($tabletcostsum, 2),2) |