Example 1 — Whole number division
Divide a few numbers and keep only the whole part.
<?php
echo intdiv(10, 3) . PHP_EOL;
echo intdiv(20, 5) . PHP_EOL;
echo intdiv(7, 2) . PHP_EOL; How It Works
- 10 divided by 3 is 3.33, so intdiv() returns 3.
- 20 divided by 5 is exactly 4.
- 7 divided by 2 is 3.5, and the .5 is dropped, giving 3.
- The return type is always int.

