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.
当用户当时在文本框中插入金额时,我想以这种格式插入金额
100.00 1,000.00
如何在 php 句点和逗号中以这种格式插入金额需要在适当的位置。
number_format($number, 2, '.', ',');
数字格式功能
像这样使用变量的数字格式
<?php $number = strip_tags($_POST['number']); echo number_format($number,2);
第二个参数number_format()是你想要一个值的级别。如果您想要最多 2 位小数,那么它将是 2。如果您只想要整数,则将其转换为int()这将对您有所帮助。:-)
number_format()
int()