3v4l.org

run code in 300+ PHP versions simultaneously
<?php function f($dividend, $divider) { $reminder = (($dividend % $divider) + abs($divider)) % abs($divider); $quotient = ($dividend - $reminder) / $divider; printf("%2d/%2d = %2d (remainder %d)\n", $dividend, $divider, $quotient, $reminder); } f(7, 3); f(7, -3); f(-7, 3); f(-7, -3);

preferences:
70.56 ms | 405 KiB | 5 Q