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

ParameterTypeWhat it takes
$num1intNumber to be divided.
$num2intNumber 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

fmod()

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.