Last active
March 15, 2021 11:50
-
-
Save krmgns/ca98b47f6d4289eab7d9a99430381b92 to your computer and use it in GitHub Desktop.
intdiv samples & polyfill.
This file contains 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 | |
// https://github.com/itchyny/gojq#difference-to-jq | |
$intdiv = fn($x, $y) => ($x - $x % $y) / $y; | |
// polyfill | |
if (!function_exists('intdiv')) { | |
function intdiv($x, $y) { | |
return ($x - $x % $y) / $y; | |
} | |
} | |
$x = 10; $y = 3; | |
var_dump($x / $y); | |
var_dump($x / $y | 0); | |
var_dump(intdiv($x, $y)); | |
var_dump($intdiv($x, $y)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment