3v4l.org

run code in 300+ PHP versions simultaneously
<?php $numbers = array ( 0 => 27, 1 => 24, 2 => 84, 3 => 43, 4 => 8, 5 => 51, 6 => 60, 7 => 86, 8 => 9, 9 => 48, 10 => 67, 11 => 20, 12 => 44, 13 => 85, 14 => 6, 15 => 63, 16 => 41, 17 => 32, 18 => 64, 19 => 73, 20 => 43, 21 => 24, 22 => 15, 23 => 19, 24 => 9, 25 => 93, 26 => 88, 27 => 77, 28 => 11, 29 => 54, ); sort($numbers); var_export($numbers); $count = sizeof($numbers); // cache the count $index = floor($count/2); // cache the index if (!$count) { echo "no values"; } elseif ($count & 1) { // count is odd echo $numbers[$index]; } else { // count is even echo ($numbers[$index-1] + $numbers[$index]) / 2; }
Output for git.master, git.master_jit, rfc.property-hooks
array ( 0 => 6, 1 => 8, 2 => 9, 3 => 9, 4 => 11, 5 => 15, 6 => 19, 7 => 20, 8 => 24, 9 => 24, 10 => 27, 11 => 32, 12 => 41, 13 => 43, 14 => 43, 15 => 44, 16 => 48, 17 => 51, 18 => 54, 19 => 60, 20 => 63, 21 => 64, 22 => 67, 23 => 73, 24 => 77, 25 => 84, 26 => 85, 27 => 86, 28 => 88, 29 => 93, )43.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:
135.62 ms | 406 KiB | 5 Q