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
Assuming the number is encoded as or cast to a string, here's a general purpose approach:
$value = is_numeric($value) ? strval($value + 0) : $value;