3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $array = array( array('value' => 1), array('value' => 2), array('value' => 2), //Move this array('value' => 2), //Move the also second duplicate array('value' => 'A'), array('value' => 'B'), array('value' => 'C'), array('value' => 6), array('value' => 7), array('value' => 7), //Move this array('value' => 8), array('value' => 9), array('value' => 10), array('value' => 11) ); usort($array, function($a, $b){ return strcmp($a['value'], $b['value']);}); $chunks = array_chunk($array, ceil(count($array)/5)); $array = array(); for($x = 0, $numX = count($chunks[0]); $x < $numX; $x++){ for($y = 0, $numY = count($chunks); $y < $numY; $y++){ if(isset($chunks[$y][$x])) $array[] = $chunks[$y][$x]; } } print_r($array);
Output for 5.3.0 - 7.1.0
Array ( [0] => Array ( [value] => 1 ) [1] => Array ( [value] => 2 ) [2] => Array ( [value] => 6 ) [3] => Array ( [value] => 8 ) [4] => Array ( [value] => B ) [5] => Array ( [value] => 10 ) [6] => Array ( [value] => 2 ) [7] => Array ( [value] => 7 ) [8] => Array ( [value] => 9 ) [9] => Array ( [value] => C ) [10] => Array ( [value] => 11 ) [11] => Array ( [value] => 2 ) [12] => Array ( [value] => 7 ) [13] => Array ( [value] => A ) )
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION in /in/KM37R on line 20
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 T_FUNCTION in /in/KM37R on line 20
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/KM37R on line 20
Process exited with code 255.