intdiv()
intdiv() — Integer division.
Built-in function of PHP 8.5. The manual lists it as available in PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.
What it does
Returns the integer quotient of the division of num1 by num2.
Signature
intdiv(int $num1, int $num2): int
Parameters
| Parameter | Type | What it takes |
|---|---|---|
| $num1 | int | Number to be divided. |
| $num2 | int | Number which divides the num1. |
Return value
The integer quotient of the division of num1 by num2.
Example
A runnable snippet:
var_dump(intdiv(3, 2)); var_dump(intdiv(-3, 2)); var_dump(intdiv(3, -2)); var_dump(intdiv(-3, -2)); var_dump(intdiv(PHP_INT_MAX, PHP_INT_MAX)); var_dump(intdiv(PHP_INT_MIN, PHP_INT_MIN));
Output:
int(1) int(-1) int(-1) int(1) int(1) int(1)
See also
All PHP 8.5 built-in functions
Reference card built from the PHP manual page intdiv() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.