fmod()

arisdelaCruz1413618857's avatar
Published Jul 20, 2023
Contribute to Docs

The fmod() function returns the remainder (modulo) of x/y. The name stands for “floating modulo” and the function calculates the modulo of any division which may contain a float as both dividend and divisor.

Syntax

fmod(x,y);

The function takes two required parameters - the x specifies the dividend and the y specifies the divisor.

Example

This example returns the remainder of x and y.

<?php
$x = 27;
$y = 5;
$remainder = fmod($x,$y);
echo $remainder;
?>

The output will be:

2

All contributors

Contribute to Docs

Learn PHP on Codecademy