Computer >> Computer tutorials >  >> Programming >> PHP

gmp_div_qr() function in PHP


The gmp_div_qr() function performs the division operation between two GMP numbers.

Syntax

gmp_div_qr(n1, n2)

Parameters

  • n1 − The first GMP number. It can be GMP object in PHP version 5.6 and later. Can also be numeric strings.

  • n2 − The second GMP number. It can be GMP object in PHP version 5.6 and later. Can also be numeric strings.

Return

The gmp_div_qr()function returns the quotient and remainder of the division. This will be displayed in an array.

Example

The following is an example −

<?php
   $n1 = gmp_init(129);
   $n2 = gmp_init(9);
   $a = gmp_div_qr(n1, n2);
   echo $a;
?>

Output

The following is the output −

Array
(
   [0] => GMP Object ( [num] => 14 )
   [1] => GMP Object ( [num] => 3 )
)