Having the following decimal numbers:
- 47.44
- 180.11
- 340
- 12.39
- 25
I was wondering, how can I add a default .00
to those numbers, that have no decimals?
Having the following decimal numbers:
I was wondering, how can I add a default .00
to those numbers, that have no decimals?
You can use number_format()
like that:
number_format($number, 2);
It'll always return number with two decimals. Also it'll separate thousands with ',' (if you don't want that, add '' as fourth parameter).