我如何保持两个零在php中取整 [英] how do i round in php with keeping the two zeros
本文介绍了我如何保持两个零在php中取整的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个php
<?php echo round($price, 2); ?>
和$price
也许1.0000
我想要1.00
,但我只得到1
任何想法
推荐答案
以下printf()
调用应该对您有用:
The following printf()
call should work for you:
<?php printf("%.2f", $price); ?>
有关此语法的文档,最好在 sprintf()
页上进行描述.
The documentation for this syntax is best described on the sprintf()
page.
这篇关于我如何保持两个零在php中取整的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文