3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $q = range(0, 100); $result = array(); foreach($q as $key => $value) { if (0 === $value % 2) { $result[] = $key; } } var_dump($result);
based on oNBOX
Output for 4.3.0 - 7.2.0
array(51) { [0]=> int(0) [1]=> int(2) [2]=> int(4) [3]=> int(6) [4]=> int(8) [5]=> int(10) [6]=> int(12) [7]=> int(14) [8]=> int(16) [9]=> int(18) [10]=> int(20) [11]=> int(22) [12]=> int(24) [13]=> int(26) [14]=> int(28) [15]=> int(30) [16]=> int(32) [17]=> int(34) [18]=> int(36) [19]=> int(38) [20]=> int(40) [21]=> int(42) [22]=> int(44) [23]=> int(46) [24]=> int(48) [25]=> int(50) [26]=> int(52) [27]=> int(54) [28]=> int(56) [29]=> int(58) [30]=> int(60) [31]=> int(62) [32]=> int(64) [33]=> int(66) [34]=> int(68) [35]=> int(70) [36]=> int(72) [37]=> int(74) [38]=> int(76) [39]=> int(78) [40]=> int(80) [41]=> int(82) [42]=> int(84) [43]=> int(86) [44]=> int(88) [45]=> int(90) [46]=> int(92) [47]=> int(94) [48]=> int(96) [49]=> int(98) [50]=> int(100) }