PHP去除浮点数后面多余的0

如:

5.1000  转化为5.1

6.00 转化为6

 

$str = 1.2200;
echo rtrim(rtrim($str, ‘0’), ‘.’);