PHP minimum precision on a number

cylon

New Member
I have a list of numbers coming from a database that range from 0.001 to 10 and I need to display them with a minimum precision of 2 decimal places but no maximum precision. Example numbers and expected conversion:
  • 1 -> 1.00
  • 0.1 -> 0.10
  • 0.01 -> 0.01
  • 0.001 -> 0.001
  • 1.234 -> 1.234
  • 0.035 -> 0.035
  • 25.5 -> 25.50
Any Ideas?
 
Back
Top