PHP intdiv() Function
The PHP intdiv() function is used for integer division and returns the integer quotient of the division of given dividend and divisor.
If divisor is 0, a DivisionByZeroError exception is thrown. If the dividend is PHP_INT_MIN and the divisor is -1, then an ArithmeticError exception is thrown.
Syntax
intdiv(dividend, divisor)
Parameters
dividend |
Required. Specify the dividend. |
divisor |
Required. Specify the divisor. |
Return Value
Returns true the integer quotient of the division of given dividend and divisor.
Example:
In the example below, intdiv() function returns the integer quotient.
<?php echo "intdiv(25, 7) = ".intdiv(25, 7)."\n"; echo "intdiv(-25, 7) = ".intdiv(-25, 7)."\n"; echo "intdiv(25, -7) = ".intdiv(25, -7)."\n"; echo "intdiv(-25, -7) = ".intdiv(-25, -7)."\n"; ?>
The output of the above code will be:
intdiv(25, 7) = 3 intdiv(-25, 7) = -3 intdiv(25, -7) = -3 intdiv(-25, -7) = 3
❮ PHP Math Reference