Skip to content

Instantly share code, notes, and snippets.

@perusio
Created January 20, 2012 01:39
Show Gist options
  • Select an option

  • Save perusio/1644446 to your computer and use it in GitHub Desktop.

Select an option

Save perusio/1644446 to your computer and use it in GitHub Desktop.
Integer division in PHP
<?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