PHP fmod() Function

❮ PHP Math Reference

Example

Return the remainder of x/y:

<?php
echo(fmod(20, 4) . "<br>");
echo(fmod(20, 3) . "<br>");
echo(fmod(15, 6) . "<br>");
echo(fmod(-10, 3) . "<br>");
echo(fmod(0, 0));
?>
Try it Yourself »

Definition and Usage

The fmod() function returns the remainder (modulo) of x/y.


Syntax

fmod(x,y);

Parameter Values

Parameter Description
x Required. Specifies the dividend
y Required. Specifies the divisor

Technical Details

Return Value: The floating point remainder of x/y
Return Type: Float
PHP Version: 4.2+

❮ PHP Math Reference
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.