3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $count = 5; $last = 4; foreach (range(-5, 4, 1) as $v) { if ($v < 0) { print $v . ': ' .$v % $count . ' ' . ((($v % $count) + $count) % $count + 1) . "\n"; } else { print $v . ': ' .$v % $count . ' ' . (($v % $count) + $count) % $count . "\n"; } }
based on SdGLh
Output for 5.0.0 - 5.6.21, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
-5: 0 1 -4: -4 2 -3: -3 3 -2: -2 4 -1: -1 5 0: 0 0 1: 1 1 2: 2 2 3: 3 3 4: 4 4
Output for 4.3.0 - 4.3.10, 4.4.0 - 4.4.9
Warning: Wrong parameter count for range() in /in/UMQVu on line 6 Warning: Invalid argument supplied for foreach() in /in/UMQVu on line 6
Output for 4.3.11
Warning: Wrong parameter count for range() in /in/UMQVu on line 6