3v4l.org

run code in 300+ PHP versions simultaneously
<?php function countingSort(array $arr) { $n = sizeof($arr); $p = array(); $sorted = array(); for ($i = 0; $i < $n; $i++) { $p[$i] = 0; } for ($i = 0; $i < $n; $i++) { for ($j = $i + 1; $j < $n; $j++) { if ($arr[$i] > $arr[$j]) { $p[$i]++; } else { $p[$j]++; } } } for ($i = 0; $i < $n; $i++) { $sorted[$p[$i]] = $arr[$i]; } return $sorted; } // Example: $arr = array(255,1,22,3,45,5); $csresult = countingSort($arr); print_r($csresult);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [5] => 255 [0] => 1 [3] => 22 [1] => 3 [4] => 45 [2] => 5 )

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:
44.12 ms | 401 KiB | 8 Q