3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $ox = 10; $oy = 10; $x = 15; $y = 15; $sx = ($ox < $x)?1:-1; $sy = ($oy < $y)?1:-1; var_dump($sx,$sy); //Test collisions for each cell along deplacement for($dx = $ox+$sx; $sx*$dx <= $sx*$x; $dx += $sx){ for($dy = $oy+$sy; $sy*$dy <= $sy*$y; $dy += $sy){ var_dump(array($dx,$dy)); } }
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
int(1) int(1) array(2) { [0]=> int(11) [1]=> int(11) } array(2) { [0]=> int(11) [1]=> int(12) } array(2) { [0]=> int(11) [1]=> int(13) } array(2) { [0]=> int(11) [1]=> int(14) } array(2) { [0]=> int(11) [1]=> int(15) } array(2) { [0]=> int(12) [1]=> int(11) } array(2) { [0]=> int(12) [1]=> int(12) } array(2) { [0]=> int(12) [1]=> int(13) } array(2) { [0]=> int(12) [1]=> int(14) } array(2) { [0]=> int(12) [1]=> int(15) } array(2) { [0]=> int(13) [1]=> int(11) } array(2) { [0]=> int(13) [1]=> int(12) } array(2) { [0]=> int(13) [1]=> int(13) } array(2) { [0]=> int(13) [1]=> int(14) } array(2) { [0]=> int(13) [1]=> int(15) } array(2) { [0]=> int(14) [1]=> int(11) } array(2) { [0]=> int(14) [1]=> int(12) } array(2) { [0]=> int(14) [1]=> int(13) } array(2) { [0]=> int(14) [1]=> int(14) } array(2) { [0]=> int(14) [1]=> int(15) } array(2) { [0]=> int(15) [1]=> int(11) } array(2) { [0]=> int(15) [1]=> int(12) } array(2) { [0]=> int(15) [1]=> int(13) } array(2) { [0]=> int(15) [1]=> int(14) } array(2) { [0]=> int(15) [1]=> int(15) }