3v4l.org

run code in 300+ PHP versions simultaneously
<?php $list = [1, 2, 3, 4, 5, 6, 7, 8, 9]; $result = array_rand($list, 3); print_r ($result) ?>
Output for 8.1.9
Array ( [0] => 1 [1] => 5 [2] => 6 )
Output for 8.1.8
Array ( [0] => 2 [1] => 6 [2] => 8 )
Output for 7.4.14, 8.1.7
Array ( [0] => 1 [1] => 2 [2] => 6 )
Output for 8.1.5 - 8.1.6
Array ( [0] => 0 [1] => 2 [2] => 8 )
Output for 8.1.4
Array ( [0] => 0 [1] => 5 [2] => 8 )
Output for 8.1.3
Array ( [0] => 0 [1] => 1 [2] => 2 )
Output for 8.0.16, 8.1.2
Array ( [0] => 0 [1] => 5 [2] => 7 )
Output for 7.4.22, 8.1.1
Array ( [0] => 3 [1] => 4 [2] => 6 )
Output for 8.0.8, 8.1.0
Array ( [0] => 0 [1] => 1 [2] => 8 )
Output for 7.4.5, 8.0.22
Array ( [0] => 0 [1] => 6 [2] => 7 )
Output for 8.0.21
Array ( [0] => 2 [1] => 3 [2] => 6 )
Output for 8.0.20
Array ( [0] => 1 [1] => 2 [2] => 3 )
Output for 8.0.19
Array ( [0] => 1 [1] => 4 [2] => 7 )
Output for 8.0.18
Array ( [0] => 5 [1] => 6 [2] => 7 )
Output for 8.0.17
Array ( [0] => 2 [1] => 4 [2] => 7 )
Output for 8.0.15
Array ( [0] => 2 [1] => 4 [2] => 6 )
Output for 8.0.14
Array ( [0] => 5 [1] => 7 [2] => 8 )
Output for 8.0.13
Array ( [0] => 0 [1] => 3 [2] => 7 )
Output for 8.0.7, 8.0.12
Array ( [0] => 0 [1] => 2 [2] => 7 )
Output for 8.0.11
Array ( [0] => 0 [1] => 4 [2] => 7 )
Output for 8.0.10
Array ( [0] => 1 [1] => 2 [2] => 7 )
Output for 8.0.9
Array ( [0] => 4 [1] => 5 [2] => 6 )
Output for 7.4.24, 8.0.1, 8.0.6
Array ( [0] => 0 [1] => 1 [2] => 3 )
Output for 8.0.5
Array ( [0] => 4 [1] => 5 [2] => 8 )
Output for 7.4.16, 8.0.3
Array ( [0] => 1 [1] => 2 [2] => 5 )
Output for 7.4.3, 7.4.21, 8.0.2
Array ( [0] => 4 [1] => 7 [2] => 8 )
Output for 7.4.30
Array ( [0] => 3 [1] => 7 [2] => 8 )
Output for 7.4.29
Array ( [0] => 1 [1] => 6 [2] => 7 )
Output for 7.4.28
Array ( [0] => 2 [1] => 6 [2] => 7 )
Output for 7.4.27
Array ( [0] => 0 [1] => 7 [2] => 8 )
Output for 7.4.19, 7.4.26
Array ( [0] => 0 [1] => 3 [2] => 5 )
Output for 7.4.25
Array ( [0] => 1 [1] => 2 [2] => 8 )
Output for 7.4.23
Array ( [0] => 4 [1] => 5 [2] => 7 )
Output for 7.4.0, 7.4.20
Array ( [0] => 0 [1] => 2 [2] => 3 )
Output for 7.4.18
Array ( [0] => 2 [1] => 5 [2] => 8 )
Output for 7.4.15
Array ( [0] => 0 [1] => 1 [2] => 5 )
Output for 7.4.13
Array ( [0] => 0 [1] => 1 [2] => 4 )
Output for 7.4.8, 7.4.12
Array ( [0] => 0 [1] => 5 [2] => 6 )
Output for 7.4.2, 7.4.11
Array ( [0] => 1 [1] => 3 [2] => 7 )
Output for 7.4.10
Array ( [0] => 1 [1] => 3 [2] => 8 )
Output for 7.4.7, 7.4.9
Array ( [0] => 1 [1] => 3 [2] => 5 )
Output for 7.4.6
Array ( [0] => 4 [1] => 6 [2] => 7 )
Output for 7.4.4
Array ( [0] => 1 [1] => 4 [2] => 8 )
Output for 7.4.1
Array ( [0] => 3 [1] => 6 [2] => 7 )

preferences:
22.19 ms | 469 KiB | 5 Q