3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $res = array(); foreach ( range(0, 20) as $i ) { $res[$i % 10][] = $i; } var_dump($res);
based on oYXl2
Output for 5.5.0 - 7.2.0
array(10) { [0]=> array(3) { [0]=> int(0) [1]=> int(10) [2]=> int(20) } [1]=> array(2) { [0]=> int(1) [1]=> int(11) } [2]=> array(2) { [0]=> int(2) [1]=> int(12) } [3]=> array(2) { [0]=> int(3) [1]=> int(13) } [4]=> array(2) { [0]=> int(4) [1]=> int(14) } [5]=> array(2) { [0]=> int(5) [1]=> int(15) } [6]=> array(2) { [0]=> int(6) [1]=> int(16) } [7]=> array(2) { [0]=> int(7) [1]=> int(17) } [8]=> array(2) { [0]=> int(8) [1]=> int(18) } [9]=> array(2) { [0]=> int(9) [1]=> int(19) } }