PHP fmod() Function

Definition and Usage

The fmod() function returns the floating-point remainder of the division.

Syntax

fmod(x,y)
Parameter Description
x Required. A number.
y Required. A number.

Description

xy i is an integer. If y is a non-zero value, then r and x has the same sign and its magnitude is less than y .

Example

In this example, we will use the fmod() function to return the remainder of 5/2:

<?php
$r = fmod(5,2);
echo $r
?>

Output:

1