What is the best way to remove zero before decimal point in php? These are the two I know of:
ltrim(0.357, '0'); //.357
preg_replace("/0\./i", ".", 0.357); //.357
Are there any better method? Which of them is faster?
What is the best way to remove zero before decimal point in php? These are the two I know of:
ltrim(0.357, '0'); //.357
preg_replace("/0\./i", ".", 0.357); //.357
Are there any better method? Which of them is faster?
You can do it mathematically with floor() function
$n = 0.375;
$whole = floor($n); // 0
$fraction = $n - $whole; // .375