Home >>PHP Math Functions >PHP fmod() Function

PHP fmod() Function

PHP fmod() Function

PHP fmod() function is used to calculate the Modulo of any given input division which may contain float value as both dividend and divisors. It accepts two parameters, one is $dividend and the other one is $ divisor. It returns the remainder (modulo) of the division of given input values as $dividend and $divisor.

Syntax:

  fmod($dividend, $divisor);

Parameter Values

Parameter Description
Dividend This is a required parameter. This parameter defines the given dividend value.
Divisor This is a required parameter. This parameter defines the given divisor value.

Here is an example of fmod() function in PHP:

<html>
<body>

<?php

echo fmod(7,3)."<br>";   // 7 % 3
echo fmod(55,5)."<br>";  // 55 % 5
echo fmod(38,5)."<br>";  // 38 % 5

?>

</body>
</html>
Output:
1
0
3

Here is an another example of fmod() function in PHP:

<html>
<body>

<?php

$a = 5457;
$b = 45;
$x = fmod($a,$b);
echo $x."<br>";

$c =3845457;
$d = 45;
$y = fmod($c,$d);
echo $y."<br>";

$e =384545723;
$f = 455;
$z = fmod($e,$f);
echo $z."<br>";

?>

</body>
</html>
Output:
12
27
198