Question: Keep 1 decimal place, do not round, fill in 0 when it is an integer
Many people say to usesprintf('%.1f',$str);
, but there are still problems with the results.
Finally, this method was used to solve the problem:echo sprintf('%.1f', floor( $str));
Didn’t you say you don’t want to round? Why is it that when rounding, 5 is not included but 6 is included?
But other functionsnumber_format($str)
are all included at 5. Why is this?