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?
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?
Be careful with adding +0.
Result of this is 1.
Thats my small solution... Can included to a class and set vars
private $dsepparator = '.'; // decimals private $tsepparator= ','; // thousand
That can be set by constructor and change to users lang.
I found this solution is the best: