I have a float number. I want to convert it to a string with the following two rules
- If the float has no decimal part then do not create any decimal part
- If the float has a decimal part then convert it to two decimal places
For example
499 => "499"
499.5 => "499.50"
499.99 => "499.99"
499.989 => "499.99"
How would you do that in php?