Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想将一个数字四舍五入,例如 269.00,然后将其四舍五入
round($price, 2)
它输出 269,但是当我有一个像 269.50 这样的值时,它输出 269.5,我希望最后有零,这是为产品定价
之后使用number_format:
number_format
$price = number_format(round($price, 2), 2);
这也将逗号添加为千位分隔符。