0

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?

Alex
  • 7,330
  • 20
  • 78
  • 147

1 Answers1

4

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).

Elon Than
  • 9,292
  • 4
  • 25
  • 37