note 121333 deleted from language.operators.arithmetic by salathe
| From: | salathe@php.net | Date: | Mon, 21 Sep 2020 14:58:06 +0000 |
| Subject: | note 121333 deleted from language.operators.arithmetic by salathe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-215397@lists.php.net to get a copy of this message | ||
Note Submitter: peter at icb dot at
----
If you need the mathematical modulo (always positive) from negative numbers, use this small
function:
<?php
function modulo($a , $b) { return ($a + $b) % $b; }
// examples:
echo modulo(15, 12); // 3
echo modulo(-9, 12); // 3
?>