PHP向上或向下舍入数字内的数字_格式()

PHP向上或向下舍入数字内的数字_格式(),php,Php,我有这样的想法: $exp = 1555678; 如果我将$exp放入number\u format()中,结果将如下所示: echo number_format($exp);//1,555,678 echo round(number_format($exp));//1 如果我把它们放在round()函数中,函数会是这样的: echo number_format($exp);//1,555,678 echo round(number_format($exp));/

我有这样的想法:

$exp = 1555678;
如果我将$exp放入number\u format()中,结果将如下所示:

   echo number_format($exp);//1,555,678
   echo round(number_format($exp));//1
如果我把它们放在round()函数中,函数会是这样的:

   echo number_format($exp);//1,555,678
   echo round(number_format($exp));//1
但我需要大约1556000

不管exp是什么,它都应该在第一个逗号后只舍入3个数字

还是有其他方法处理这个案子


您可以将这两种方法结合起来

$exp = 1555678;
echo number_format(round($exp, -3));

它给出:1556000除以1000,四舍五入,乘以1000数字格式返回一个字符串。round()的数据类型输入是什么。提示:不是string@Andreas这是float..在发布问题之前请先搜索一下。@mickmackusa我真的很感谢你的帮助,谢谢这个问题是重复的。@mickmackusa我的错,我回答时不是这样:)(从2011年3月1日起就是重复的)好的,伙计,我得回去工作了谢谢你不厌其烦地回答我的问题:D