I have this code to remove unnecessary zero in decimals :
$decimal = rtrim(sprintf('%f',floatval($decimal)),'0');
it works with these numbers :
10.0050000 -> 10.005
0.0050000 -> 0.005
but not with this :
10.00 -> 10.
there's a dot after 10.
how to remove unnecessary zero in decimals, but also works for numbers like 10.00
thanks.