<?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 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.4, 8.3.6 - 8.3.7
- 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
- Output for 8.3.5
- Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
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
preferences:
321.74 ms | 402 KiB | 470 Q