Divide integer and get integer value
In PHP, you can divide two integers using the forward slash (/) operator. To get the integer value of the division, you can use the "intval" function. For example:
<?php
$dividend = 10;
$divisor = 3;
$quotient = intval($dividend / $divisor);
echo $quotient; // Output: 3
Watch a video course
Learn object oriented PHP
Alternatively, you can use the "floor" function which gives the largest integer less than or equal to the division of two numbers.
<?php
$dividend = 10;
$divisor = 3;
$quotient = floor($dividend / $divisor);
echo $quotient; // Output: 3
You can also use the division operator % which returns the remainder of a division.
<?php
$dividend = 10;
$divisor = 3;
$quotient = $dividend % $divisor;
echo $quotient; // Output: 1