我想显示 or 2.00而不是or 2或or 3.50而不是GB3.5。
假设price在MySQL数据库中定义为DOUBLE。如何强制MySQL或PHP显示这两个小数?
非常感谢!
发布于 2012-05-11 21:50:51
试试这个:
echo number_format ($price, 2);发布于 2012-05-11 21:58:42
对于MySQL,可以使用format函数:
SELECT FORMAT(1.2345, 2);它将返回1.23
对于PHP,您可以以类似的方式使用number_format:
echo number_format(1.2345, 2);也打印1.23
发布于 2012-05-11 21:50:01
number_format和money_format是你的朋友!
https://stackoverflow.com/questions/10559075
复制相似问题