3v4l.org

run code in 300+ PHP versions simultaneously
<?php function mergeSort($array) { echo "array = " . json_encode($array) . "\n"; $count = count($array); if ($count == 1) { return $array; } $middle = $count / 2; // round/floor/ceil is unnecessary return merge( mergeSort(array_slice($array, 0, $middle)), mergeSort(array_slice($array, $middle)) ); } function merge($half1, $half2) { do { $temp[] = $half1[0] < $half2[0] ? array_shift($half1) : array_shift($half2); } while(isset($half1[0], $half2[0])); return array_merge($temp, $half1, $half2); } $input = [4, 2, 7, 5, 3]; $input = mergeSort($input); var_export($input);
Output for git.master, git.master_jit, rfc.property-hooks
array = [4,2,7,5,3] Deprecated: Implicit conversion from float 2.5 to int loses precision in /in/REQAa on line 11 array = [4,2] array = [4] array = [2] Deprecated: Implicit conversion from float 2.5 to int loses precision in /in/REQAa on line 12 array = [7,5,3] Deprecated: Implicit conversion from float 1.5 to int loses precision in /in/REQAa on line 11 array = [7] Deprecated: Implicit conversion from float 1.5 to int loses precision in /in/REQAa on line 12 array = [5,3] array = [5] array = [3] array ( 0 => 2, 1 => 3, 2 => 4, 3 => 5, 4 => 7, )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
34.23 ms | 407 KiB | 5 Q