Related questions
Remove useless zero digits from decimals in PHP
I'm trying to find a fast way to remove zero decimals from number values like this:
echo cleanNumber('125.00');
// 125
echo cleanNumber('966.70');
// 966.7
echo cleanNumber(844.011);
// 844.011
Does exists some optimized way to do that?
Check if number is decimal
I need to check in PHP if user entered a decimal number (US way, with decimal point: X.XXX)
Any reliable way to do this?
PHP How do I round down to two decimal places?
I need to round down a decimal in PHP to two decimal places so that:
49.955
becomes...
49.95
I have tried number_format, but this just rounds the value to 49.96. I cannot use substr because the number may be smaller (such as 7.950). …