dsfsdfsd34324
2019-07-16 17:40
浏览 59
已采纳

如何在PHP中将数字从621编译到700?

$num=621;
echo round(round(621,-2));

图片转代码服务由CSDN问答提供 功能建议

  $ num = 621; 
echo round(round(621,-2)); 
 <  / code>  
 
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

4条回答 默认 最新

  • duangai1368 2019-07-16 21:15
    最佳回答

    I think you are trying to round off a number to the nearest 100. Simply do this by using the ceil function.

    ceil(621 / 100) * 100;
    

    You can use ceil function to round any number to its nearest number.

    $number = ceil($inputNumber / $nearestNumber) * $nearestNumber;
    
    评论
    解决 无用
    打赏 举报
查看更多回答(3条)