In PHP (using built-in functions) I\'d like to convert/format a number with decimal, so that only the non-zero decimals show. However, another requirement of mine is that if
If you want a built-in solution and you're using a PHP version later than 4.2 you could try floatval():
echo floatval(9.200);
prints
9.2
but
echo floatval(9.123);
9.123
Hope this helps.