How to round to nearest Thousand?

前端 未结 8 627
独厮守ぢ
独厮守ぢ 2020-12-06 03:59

How Do I round a number to its nearest thousand?

function round($var) {
    // Round it
}
8条回答
  •  离开以前
    2020-12-06 04:56

    For positive integers:

    function round($var) {
        return ($var + 500) / 1000 * 1000;
    }
    

提交回复
热议问题