3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $data = array(8,4,1,9,5,7,3,2,6,0); function merge_sort($list){ if(count($list) <= 1) { return $list; } $middle = count($list)/2; $left = merge_sort(array_slice($list, 0, $middle)); $right = merge_sort(array_slice($list, $middle, count($list))); print_r(array_merge($left, $right)); } merge_sort($data);
based on ZOcmn
Output for 5.3.0 - 7.1.0
Array ( [0] => 8 [1] => 4 ) Array ( [0] => 9 [1] => 5 ) Warning: array_merge(): Argument #2 is not an array in /in/uBjZa on line 14 Warning: array_merge(): Argument #1 is not an array in /in/uBjZa on line 14 Array ( [0] => 7 [1] => 3 ) Array ( [0] => 6 [1] => 0 ) Warning: array_merge(): Argument #2 is not an array in /in/uBjZa on line 14 Warning: array_merge(): Argument #1 is not an array in /in/uBjZa on line 14 Warning: array_merge(): Argument #1 is not an array in /in/uBjZa on line 14
Output for 5.0.0 - 5.2.17
Array ( [0] => 8 [1] => 4 ) Array ( [0] => 9 [1] => 5 ) Warning: array_merge(): Argument #2 is not an array in /in/uBjZa on line 14 Warning: array_merge(): Argument #1 is not an array in /in/uBjZa on line 14 Warning: array_merge(): Argument #2 is not an array in /in/uBjZa on line 14 Array ( [0] => 7 [1] => 3 ) Array ( [0] => 6 [1] => 0 ) Warning: array_merge(): Argument #2 is not an array in /in/uBjZa on line 14 Warning: array_merge(): Argument #1 is not an array in /in/uBjZa on line 14 Warning: array_merge(): Argument #2 is not an array in /in/uBjZa on line 14 Warning: array_merge(): Argument #1 is not an array in /in/uBjZa on line 14 Warning: array_merge(): Argument #2 is not an array in /in/uBjZa on line 14
Output for 4.3.0 - 4.4.9
Array ( [0] => 8 [1] => 4 ) Array ( [0] => 9 [1] => 5 ) Array ( [0] => 1 ) Array ( ) Array ( [0] => 7 [1] => 3 ) Array ( [0] => 6 [1] => 0 ) Array ( [0] => 2 ) Array ( ) Array ( )