Return the remainder of x/y in PHP

Description

The following code shows how to return the remainder of x/y.

Example


/*  w ww . j  av  a 2  s. c  om*/
<?php
    $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 »
    Development »




Environment
Error
Hash
Include
Locale
Math
Network
Output
Reflection
PHP Regular Expressions