How to divide numbers without remainder in PHP?

前端 未结 6 1889
抹茶落季
抹茶落季 2020-12-29 18:08

How does one divide numbers but exclude the remainder in PHP?

6条回答
  •  滥情空心
    2020-12-29 18:53

    Just cast the resulting value to an int.

    $n = (int) ($i / $m);
    

    Interesting functions (depending on what you want to achieve and if you expect negative integers to get devided) are floor(), ceil() and round().

提交回复
热议问题