PHP program to find integer division using intdiv() function

PHP intdiv() function example: Here, we will figure out how to discover the integer division of two given numbers in PHP utilizing intdiv() function?

Given two numbers and we need to discover their division in PHP.

To discover an integer division of two numbers in PHP, we can utilize intdiv() function, it acknowledges profit and divisor and returns the outcome as an integer.


    intdiv(divident, divisor);


    $a = 10;
    $b = 3;

    Function call:
    intdiv($a, $b);


intdiv() example in PHP

Here we are finding the division utilizing two different ways 1) dividend/divisor – the outcome is a buoy value and 2) intdiv(dividend, divisor) – the outcome is an integer value.

    $a = 10;
    $b = 3;
    //normal division
    $result1 = $a/$b;
    print("value of result1: $result1 \n");
    print("var_dump: ");
    //using intdiv() function
    $result2 = intdiv($a, $b);
    print("value of result2: $result2 \n");
    print("var_dump: ");


value of result1: 3.3333333333333
var_dump: float(3.3333333333333)

value of result2: 3
var_dump: int(3)

Leave a Comment

error: Alert: Content is protected!!