php取一位小数,在线等
$str = 35.5454;
现想取 35.5
怎么实现呀,
------解决方案--------------------
$result = round(35.5454,1); <br><font color="#e78608">------解决方案--------------------</font><br>$str = 35.5454;<br>$str = number_format($str, 1); <br>echo $str; <br><font color="#e78608">------解决方案--------------------</font><br>
$str = 35.5454;
$num =number_format($str,1)
<br><font color="#e78608">------解决方案--------------------</font><br>$xxx=sprintf('%.1f',$xxx);
<br><font color="#e78608">------解决方案--------------------</font><br>$result = round(35.5454,1);
<br><font color="#e78608">------解决方案--------------------</font><br>结帖给分吧。<br>真的在线么????
<br><font color="#e78608">------解决方案--------------------</font><br>sprintf('%0.1f',$str);
<br><font color="#e78608">------解决方案--------------------</font><br>飘过!
<br><font color="#e78608">------解决方案--------------------</font><br>round(35.5454,1);
<br><font color="#e78608">------解决方案--------------------</font><br>round(3.14159,1);<br><br>number_format(3.14159265,1,'.','');//这个效果更佳,尾数是 0 ,会自动补上0的
<br><font color="#e78608">------解决方案--------------------</font><br>
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号