I have number:
- 2000
- 100
- 0.1
- 0.15
- 0.1555
But I need show these number in this format:
- 2,000.00
- 100.00
- 0.10
- 0.15
- 0.1555
I will never have more than 4 decimals after decimal separator. If after decimal separator are only null, I need to display 2 nulls (3. example above).
How I can format these numbers to get required format? Thank you!
EDIT: I can't use just number_format
function, because with this function I can only set how many decimals will be after decimal separator, but as I wrote above - sometimes there will be 2, sometimes 4. So, if my number is 2000.0001
and I set this number_format(2000.0001, 4)
output will be 2000.0001
, but other number like 0.1
will output 0.1000
, but I need it with 0.10
format.