PHP fmod() Function

Definition

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

Syntax

PHP fmod() Function has the following syntax.

fmod(x,y);

Parameter

ParameterIs Required Description
xRequired. Dividend
y Required.Divisor

Return

Item Description
Return Value The floating point remainder of x/y
Return Type Float

Example

Return the remainder of x/y:


<?php/* w w  w.j  a  va  2s  . c  o  m*/
$x = 7;
$y = 2;
$result = fmod($x,$y);
echo $result;

?>

$result equals 1, because 2 * 3 + 1 = 7

The code above generates the following result.





















Home »
  PHP Tutorial »
    Function reference »




PHP Array Functions
PHP Calendar Functions
PHP Class Functions
PHP Data Type Functions
PHP Date Functions
PHP File Functions
PHP Image Functions
PHP Math Functions
PHP MySQLi Functions
PHP SimpleXML Functions
PHP String Functions
PHP XML Functions
PHP Zip Functions