I am trying to figure out a way to produce the following output:
4.0000 = 4.00
4.5000 = 4.50
4.454= 4.454
4.54545454 = 4.5455
4.450 = 4.45
Basically I want to make sure there is ALWAYS at least 2 decimal places and if there are extra zeros, trim to 2 decimal places. If there is more than 4 decimal places round and keep at 4.
I can use:
number_format($number, 4, '.', '');
then rtrim to remove zeros, but this will leave me with less than 2 decimal places in many cases.