I can find reminder by "%" operator . But how can I find the quotient at the same time . Suppose I will divide 10 by 3 . If there is any function which will give me the output 3 as quotient and 1 as reminder .
The fmod() function returns the remainder (modulo) of x/y.
The division operator ("/") returns a float value unless the two operands are integers (or strings that get converted to integers) and the numbers are evenly divisible, in which case an integer value will be returned. For integer division, see intdiv(). Operands of modulo are converted to int before processing.
What Does the Modulo Operator Do? If you have two variables $a and $b , calculating $a % $b —usually pronounced "a modulo b" or "a mod b"—will give you the remainder after dividing $a by $b . Modulo is an integer operator, so it converts both the operands to integers before calculating the remainder.
The intdiv() is PHP mathematical function of PHP, which is used to calculate integer division. It returns the integer quotient of the division of dividend by divisor.
$remainder = $a % $b;
$quotient = ($a - $remainder) / $b;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With