In my case, I did the following by adding other answers here:
rtrim((strpos($number,".") !== false ? rtrim($number, "0") : $number),".");
Because I also had to remove the decimal if an integer was shown
As an example, this will show the following numbers
2.00, 1.00, 28.50, 16.25
how
2, 1, 28.5, 16.25
Instead
2., 1., 28.5, 16.25
Which, for me, does not show them correctly.
Last editing also stops numbers, such as "100", from rtrim'ed to 1, only trimming the rightmost 0 if a decimal is encountered.
Warren Sergent Oct 17 '12 at 23:24 2012-10-17 23:24
source share