The gmp_mod() function in PHP is used for the modulo operation. It accepts two parameters, such as, num1 and num2. The method calculates num1 modulo num2, such as, num1 % num2. The sign of num2 is ignored, and the result is always positive.
gmp_mod(GMP|int|string $num1, GMP|int|string $num2): GMP
num1: This parameter can be a GMP object, integer, or a string.num2: This parameter can be a GMP object, integer, or a string.The method returns a GMP object which is the result of num1 mod num2.
Let’s look at the code below:
<?php$remainder = gmp_mod(11, 7);print "11 mod 7 = ".$remainder."\n";$remainder = gmp_mod("15", 2);print "15 mod 2 = ".$remainder."\n";?>
gmp_mod() function and pass 11 and 7 as arguments.gmp_mod() function and pass 15 and 2 as arguments. Here, 15 is passed as a string.Free Resources