Divide integer and get integer value

use round() function to get integer rounded value.

round(8 / 3); // 3

or

Use floor() function to get integer value

floor(8 / 3); // 2

In PHP 7, there is intdiv function doing exactly what you want.

Usage:

intdiv(8, 3);

Returns 2.


There is no integer division operator in PHP. 1/2 yields the float 0.5. The value can be casted to an integer to round it downwards, or the round() function provides finer control over rounding.


var_dump(25/7);           // float(3.5714285714286)    
var_dump((int) (25/7));   // int(3)   
var_dump(round(25/7));    // float(4)     

PhP manual