I use the floatval()
function to remove useless 0
s, but I want to keep at least 3 significant numbers. Like if I have 0.1800000
I want to show 0.180
and if I have 1.8454214
I want to show 1.845421
. How can I do a round after 6 digits and remove useless 0
s after 3 digits?
$value = 1.80000;
$value = floatval(round($value,6));
echo $value; //I get 1.8
Or if I have
$value = 1.84542146543;
$value = floatval(round($value,6));
echo $value; //I get 1.845421
And this works fine, but not if I've got a lot of 0
s.
I always need minimum 3 decimal, but it can be more.