3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $array =Array ( 869 => 87, 938 => 89, 870 => 127, 871 => 127, 940 => 127, 942 => 123, 947 => 123, 949 => 75 ); $return = array(); foreach ($array as $key => $value) $return[$value][] = $key; var_dump(array_values($return));
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
array(5) { [0]=> array(1) { [0]=> int(869) } [1]=> array(1) { [0]=> int(938) } [2]=> array(3) { [0]=> int(870) [1]=> int(871) [2]=> int(940) } [3]=> array(2) { [0]=> int(942) [1]=> int(947) } [4]=> array(1) { [0]=> int(949) } }