How to divide numbers without remainder in PHP?

eomeroff picture eomeroff · Apr 27, 2011 · Viewed 78.3k times · Source

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

Answer

KingCrunch picture KingCrunch · Apr 27, 2011

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().