3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function weight($array) { $rnd = mt_rand(0, array_sum($array)); foreach ($array as $k=>$v) { if ($rnd <= $v) { return $k; } $rnd -= $v; } } $weights = [100, 200, 1000]; $values = array_fill(0, count($weights), 0); for ($x = 0; $x < 1000; $x++) { // at the position returned by the weight function, +1 $values[weight($weights)]++; } var_dump($values);
Output for 7.1.0
array(3) { [0]=> int(68) [1]=> int(162) [2]=> int(770) }
Output for 7.0.14
array(3) { [0]=> int(83) [1]=> int(172) [2]=> int(745) }
Output for 7.0.10
array(3) { [0]=> int(76) [1]=> int(156) [2]=> int(768) }
Output for hhvm-3.12.0, 7.0.9
array(3) { [0]=> int(70) [1]=> int(157) [2]=> int(773) }
Output for 7.0.8
array(3) { [0]=> int(87) [1]=> int(166) [2]=> int(747) }
Output for 7.0.7
array(3) { [0]=> int(65) [1]=> int(157) [2]=> int(778) }
Output for 7.0.6
array(3) { [0]=> int(77) [1]=> int(150) [2]=> int(773) }
Output for 7.0.5
array(3) { [0]=> int(78) [1]=> int(158) [2]=> int(764) }
Output for 7.0.4
array(3) { [0]=> int(75) [1]=> int(128) [2]=> int(797) }
Output for 7.0.3
array(3) { [0]=> int(90) [1]=> int(152) [2]=> int(758) }
Output for 7.0.2
array(3) { [0]=> int(79) [1]=> int(160) [2]=> int(761) }
Output for 7.0.1
array(3) { [0]=> int(68) [1]=> int(151) [2]=> int(781) }
Output for 7.0.0
array(3) { [0]=> int(86) [1]=> int(155) [2]=> int(759) }
Output for hhvm-3.10.0
array(3) { [0]=> int(68) [1]=> int(149) [2]=> int(783) }
Output for 5.6.28
array(3) { [0]=> int(67) [1]=> int(165) [2]=> int(768) }
Output for 5.6.25
array(3) { [0]=> int(68) [1]=> int(168) [2]=> int(764) }
Output for 5.6.24
array(3) { [0]=> int(82) [1]=> int(164) [2]=> int(754) }
Output for 5.6.23
array(3) { [0]=> int(83) [1]=> int(154) [2]=> int(763) }
Output for 5.6.22
array(3) { [0]=> int(74) [1]=> int(150) [2]=> int(776) }
Output for 5.6.21
array(3) { [0]=> int(88) [1]=> int(167) [2]=> int(745) }
Output for 5.6.20
array(3) { [0]=> int(68) [1]=> int(155) [2]=> int(777) }
Output for 5.6.19
array(3) { [0]=> int(91) [1]=> int(167) [2]=> int(742) }
Output for 5.6.18
array(3) { [0]=> int(75) [1]=> int(149) [2]=> int(776) }
Output for 5.6.17
array(3) { [0]=> int(70) [1]=> int(137) [2]=> int(793) }
Output for 5.6.16
array(3) { [0]=> int(84) [1]=> int(170) [2]=> int(746) }
Output for 5.6.15
array(3) { [0]=> int(74) [1]=> int(156) [2]=> int(770) }
Output for 5.6.14
array(3) { [0]=> int(92) [1]=> int(154) [2]=> int(754) }
Output for 5.6.13
array(3) { [0]=> int(93) [1]=> int(144) [2]=> int(763) }
Output for 5.6.12
array(3) { [0]=> int(91) [1]=> int(137) [2]=> int(772) }
Output for 5.6.11
array(3) { [0]=> int(93) [1]=> int(155) [2]=> int(752) }
Output for 5.6.10
array(3) { [0]=> int(84) [1]=> int(175) [2]=> int(741) }
Output for 5.6.9
array(3) { [0]=> int(80) [1]=> int(138) [2]=> int(782) }
Output for 5.6.8
array(3) { [0]=> int(81) [1]=> int(149) [2]=> int(770) }
Output for 5.6.7
array(3) { [0]=> int(81) [1]=> int(150) [2]=> int(769) }
Output for 5.6.6
array(3) { [0]=> int(80) [1]=> int(141) [2]=> int(779) }
Output for 5.6.5
array(3) { [0]=> int(71) [1]=> int(141) [2]=> int(788) }
Output for 5.6.4
array(3) { [0]=> int(59) [1]=> int(167) [2]=> int(774) }
Output for 5.6.3
array(3) { [0]=> int(80) [1]=> int(144) [2]=> int(776) }
Output for 5.6.2
array(3) { [0]=> int(85) [1]=> int(129) [2]=> int(786) }
Output for 5.6.1
array(3) { [0]=> int(80) [1]=> int(147) [2]=> int(773) }
Output for 5.6.0
array(3) { [0]=> int(83) [1]=> int(144) [2]=> int(773) }
Output for 5.5.38
array(3) { [0]=> int(76) [1]=> int(162) [2]=> int(762) }
Output for 5.5.37
array(3) { [0]=> int(97) [1]=> int(138) [2]=> int(765) }
Output for 5.5.36
array(3) { [0]=> int(77) [1]=> int(174) [2]=> int(749) }
Output for 5.5.35
array(3) { [0]=> int(96) [1]=> int(149) [2]=> int(755) }
Output for 5.5.34
array(3) { [0]=> int(72) [1]=> int(181) [2]=> int(747) }
Output for 5.5.33
array(3) { [0]=> int(94) [1]=> int(150) [2]=> int(756) }
Output for 5.5.32
array(3) { [0]=> int(86) [1]=> int(148) [2]=> int(766) }
Output for 5.5.31
array(3) { [0]=> int(79) [1]=> int(151) [2]=> int(770) }
Output for 5.5.30
array(3) { [0]=> int(84) [1]=> int(135) [2]=> int(781) }
Output for 5.4.17, 5.5.29
array(3) { [0]=> int(76) [1]=> int(157) [2]=> int(767) }
Output for 5.5.28
array(3) { [0]=> int(86) [1]=> int(165) [2]=> int(749) }
Output for 5.5.27
array(3) { [0]=> int(67) [1]=> int(155) [2]=> int(778) }
Output for 5.5.26
array(3) { [0]=> int(68) [1]=> int(139) [2]=> int(793) }
Output for 5.5.25
array(3) { [0]=> int(69) [1]=> int(148) [2]=> int(783) }
Output for 5.5.24
array(3) { [0]=> int(75) [1]=> int(169) [2]=> int(756) }
Output for 5.5.23
array(3) { [0]=> int(75) [1]=> int(182) [2]=> int(743) }
Output for 5.4.16, 5.5.22
array(3) { [0]=> int(75) [1]=> int(158) [2]=> int(767) }
Output for 5.5.21
array(3) { [0]=> int(87) [1]=> int(138) [2]=> int(775) }
Output for 5.5.20
array(3) { [0]=> int(67) [1]=> int(163) [2]=> int(770) }
Output for 5.5.19
array(3) { [0]=> int(77) [1]=> int(152) [2]=> int(771) }
Output for 5.4.43, 5.5.1, 5.5.18
array(3) { [0]=> int(71) [1]=> int(152) [2]=> int(777) }
Output for 5.5.16
array(3) { [0]=> int(83) [1]=> int(148) [2]=> int(769) }
Output for 5.5.15
array(3) { [0]=> int(88) [1]=> int(158) [2]=> int(754) }
Output for 5.5.14
array(3) { [0]=> int(85) [1]=> int(154) [2]=> int(761) }
Output for 5.4.24, 5.5.13
array(3) { [0]=> int(67) [1]=> int(158) [2]=> int(775) }
Output for 5.5.12
array(3) { [0]=> int(97) [1]=> int(142) [2]=> int(761) }
Output for 5.5.11
array(3) { [0]=> int(79) [1]=> int(171) [2]=> int(750) }
Output for 5.5.10
array(3) { [0]=> int(78) [1]=> int(148) [2]=> int(774) }
Output for 5.5.9
array(3) { [0]=> int(74) [1]=> int(151) [2]=> int(775) }
Output for 5.5.8
array(3) { [0]=> int(57) [1]=> int(134) [2]=> int(809) }
Output for 5.5.7
array(3) { [0]=> int(84) [1]=> int(155) [2]=> int(761) }
Output for 5.5.6
array(3) { [0]=> int(66) [1]=> int(134) [2]=> int(800) }
Output for 5.5.5
array(3) { [0]=> int(86) [1]=> int(151) [2]=> int(763) }
Output for 5.5.4
array(3) { [0]=> int(71) [1]=> int(154) [2]=> int(775) }
Output for 5.5.3
array(3) { [0]=> int(77) [1]=> int(165) [2]=> int(758) }
Output for 5.5.2
array(3) { [0]=> int(63) [1]=> int(144) [2]=> int(793) }
Output for 5.5.0
array(3) { [0]=> int(62) [1]=> int(163) [2]=> int(775) }
Output for 5.4.45
array(3) { [0]=> int(73) [1]=> int(140) [2]=> int(787) }
Output for 5.4.44
array(3) { [0]=> int(83) [1]=> int(156) [2]=> int(761) }
Output for 5.4.42
array(3) { [0]=> int(65) [1]=> int(155) [2]=> int(780) }
Output for 5.4.41
array(3) { [0]=> int(77) [1]=> int(159) [2]=> int(764) }
Output for 5.4.40
array(3) { [0]=> int(88) [1]=> int(148) [2]=> int(764) }
Output for 5.4.39
array(3) { [0]=> int(69) [1]=> int(142) [2]=> int(789) }
Output for 5.4.38
array(3) { [0]=> int(62) [1]=> int(153) [2]=> int(785) }
Output for 5.4.37
array(3) { [0]=> int(76) [1]=> int(166) [2]=> int(758) }
Output for 5.4.36
array(3) { [0]=> int(78) [1]=> int(132) [2]=> int(790) }
Output for 5.4.35
array(3) { [0]=> int(93) [1]=> int(150) [2]=> int(757) }
Output for 5.4.34
array(3) { [0]=> int(78) [1]=> int(153) [2]=> int(769) }
Output for 5.4.32
array(3) { [0]=> int(68) [1]=> int(140) [2]=> int(792) }
Output for 5.4.31
array(3) { [0]=> int(61) [1]=> int(143) [2]=> int(796) }
Output for 5.4.30
array(3) { [0]=> int(68) [1]=> int(156) [2]=> int(776) }
Output for 5.4.29
array(3) { [0]=> int(69) [1]=> int(155) [2]=> int(776) }
Output for 5.4.28
array(3) { [0]=> int(85) [1]=> int(139) [2]=> int(776) }
Output for 5.4.27
array(3) { [0]=> int(66) [1]=> int(161) [2]=> int(773) }
Output for 5.4.26
array(3) { [0]=> int(78) [1]=> int(160) [2]=> int(762) }
Output for 5.4.25
array(3) { [0]=> int(80) [1]=> int(166) [2]=> int(754) }
Output for 5.4.23
array(3) { [0]=> int(87) [1]=> int(156) [2]=> int(757) }
Output for 5.4.22
array(3) { [0]=> int(80) [1]=> int(159) [2]=> int(761) }
Output for 5.4.21
array(3) { [0]=> int(66) [1]=> int(170) [2]=> int(764) }
Output for 5.4.20
array(3) { [0]=> int(70) [1]=> int(164) [2]=> int(766) }
Output for 5.4.19
array(3) { [0]=> int(83) [1]=> int(145) [2]=> int(772) }
Output for 5.4.18
array(3) { [0]=> int(94) [1]=> int(136) [2]=> int(770) }
Output for 5.4.15
array(3) { [0]=> int(61) [1]=> int(164) [2]=> int(775) }
Output for 5.4.14
array(3) { [0]=> int(77) [1]=> int(143) [2]=> int(780) }
Output for 5.4.13
array(3) { [0]=> int(76) [1]=> int(143) [2]=> int(781) }
Output for 5.4.12
array(3) { [0]=> int(73) [1]=> int(159) [2]=> int(768) }
Output for 5.4.11
array(3) { [0]=> int(84) [1]=> int(153) [2]=> int(763) }
Output for 5.4.10
array(3) { [0]=> int(70) [1]=> int(151) [2]=> int(779) }
Output for 5.4.9
array(3) { [0]=> int(72) [1]=> int(141) [2]=> int(787) }
Output for 5.4.8
array(3) { [0]=> int(82) [1]=> int(147) [2]=> int(771) }
Output for 5.4.7
array(3) { [0]=> int(69) [1]=> int(157) [2]=> int(774) }
Output for 5.4.6
array(3) { [0]=> int(80) [1]=> int(150) [2]=> int(770) }
Output for 5.4.5
array(3) { [0]=> int(79) [1]=> int(148) [2]=> int(773) }
Output for 5.4.4
array(3) { [0]=> int(82) [1]=> int(154) [2]=> int(764) }
Output for 5.4.3
array(3) { [0]=> int(60) [1]=> int(135) [2]=> int(805) }
Output for 5.4.2
array(3) { [0]=> int(84) [1]=> int(147) [2]=> int(769) }
Output for 5.4.1
array(3) { [0]=> int(89) [1]=> int(149) [2]=> int(762) }
Output for 5.4.0
array(3) { [0]=> int(90) [1]=> int(146) [2]=> int(764) }
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/LdMSQ on line 17
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/LdMSQ on line 17
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/LdMSQ on line 17
Process exited with code 255.