3v4l.org

run code in 300+ PHP versions simultaneously
<?php function partition(&$arr, $left, $right) { $pivot = $arr[($left + $right)/2]; while ($left <= $right) { while ($arr[$left] < $pivot) $left++; while ($arr[$right] > $pivot) $right--; if ($left <= $right) { $tmp = $arr[$left]; $arr[$left] = $arr[$right]; $arr[$right] = $tmp; $left++; $right--; } } return $left; } function quickSort($arr, $left = 0, $right = null) { if(!$right) $right = (count($arr)-1); $index = partition($arr, $left, $right); if ($left < $index - 1) { $arr = quickSort($arr, $left, $index - 1); } if ($index < $right) { $arr = quickSort($arr, $index, $right); } return $arr; } $sortMe = [8,11,10,13,4,12,56,9]; print_r(quickSort($sortMe));
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Implicit conversion from float 3.5 to int loses precision in /in/Vm4rd on line 5 Deprecated: Implicit conversion from float 2.5 to int loses precision in /in/Vm4rd on line 5 Deprecated: Implicit conversion from float 1.5 to int loses precision in /in/Vm4rd on line 5 Deprecated: Implicit conversion from float 3.5 to int loses precision in /in/Vm4rd on line 5 Deprecated: Implicit conversion from float 6.5 to int loses precision in /in/Vm4rd on line 5 Array ( [0] => 4 [1] => 8 [2] => 9 [3] => 10 [4] => 11 [5] => 12 [6] => 13 [7] => 56 )

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:
66.77 ms | 402 KiB | 8 Q