Created
January 20, 2012 01:39
-
-
Save perusio/1644446 to your computer and use it in GitHub Desktop.
Integer division in PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Integer division in PHP. | |
| function div($x, $y) { | |
| if ($x == 0) { | |
| return 0; | |
| } | |
| elseif ($y == 0) { | |
| return FALSE; | |
| } | |
| else { | |
| return ($x - ($x % $y)) / $y; | |
| } | |
| } // div |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment