3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function columns($uarr) { $n=$uarr; if (count($n) == 0) return array(); else if (count($n) == 1) return array_chunk($n[0], 1); array_unshift($uarr, NULL); $transpose = call_user_func_array('array_map', $uarr); return array_map('array_filter', $transpose); } function bead_sort($uarr) { foreach ($uarr as $e) $poles []= array_fill(0, $e, 1); return array_map('count', columns(columns($poles))); } echo 'Original Array : '.' '; print_r(array(5,3,1,3,8,7,4,1,1,3)); echo ' '.'After Bead sort : '.' '; print_r(bead_sort(array(5,3,1,3,8,7,4,1,1,3)));
Output for 4.3.0 - 5.6.28, hhvm-3.12.0, 7.0.0 - 7.1.0
Original Array : Array ( [0] => 5 [1] => 3 [2] => 1 [3] => 3 [4] => 8 [5] => 7 [6] => 4 [7] => 1 [8] => 1 [9] => 3 ) After Bead sort : Array ( [0] => 8 [1] => 7 [2] => 5 [3] => 4 [4] => 3 [5] => 3 [6] => 3 [7] => 1 [8] => 1 [9] => 1 )
Output for hhvm-3.10.0

Process exited with code 153.