3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ 62, 9, [5, 16, 45], [11, 21, 25, 32, 50], [4, 23, 37, 57], [13, 15, 18, 22, 27, 30] ]; function getRandomValueRecursive($array) { $data = $array[array_rand($array)]; if (is_array($data)) { $data = getRandomValueRecursive($data); } return $data; } var_export(getRandomValueRecursive($array));
Output for 7.4.26, 8.0.13, 8.0.17, 8.1.0, 8.1.5, 8.1.9
9
Output for 8.1.8
23
Output for 7.4.14, 7.4.16, 7.4.22 - 7.4.24, 8.0.7, 8.0.9 - 8.0.12, 8.0.18, 8.1.7
62
Output for 8.1.6
30
Output for 8.0.15, 8.1.3 - 8.1.4
21
Output for 7.4.13, 8.0.16, 8.1.2
4
Output for 7.4.5, 8.0.20, 8.1.1
18
Output for 7.4.21, 7.4.25, 7.4.29, 8.0.8, 8.0.14, 8.0.22
16
Output for 7.4.0, 8.0.1, 8.0.21
37
Output for 7.4.1, 7.4.6, 8.0.19
57
Output for 7.4.15, 8.0.6
45
Output for 8.0.2, 8.0.5
15
Output for 7.4.9, 7.4.30, 8.0.3
5
Output for 7.4.28
27
Output for 7.4.2 - 7.4.3, 7.4.7, 7.4.10, 7.4.19, 7.4.27
50
Output for 7.4.11, 7.4.20
25
Output for 7.4.4, 7.4.8, 7.4.18
13
Output for 7.4.12
11

preferences:
60.21 ms | 430 KiB | 5 Q