3v4l.org

run code in 300+ PHP versions simultaneously
<?php $list = [1, 2, 3, 4, 5, 6, 7, 8, 9]; shuffle($list); foreach($list as $list_value){ echo array_rand($list_value, 3); } ?>
Output for 8.0.18, 8.0.20, 8.1.1, 8.1.9
Fatal error: Uncaught TypeError: array_rand(): Argument #1 ($array) must be of type array, int given in /in/HLH7g:5 Stack trace: #0 /in/HLH7g(5): array_rand(4, 3) #1 {main} thrown in /in/HLH7g on line 5
Process exited with code 255.
Output for 8.1.8
Fatal error: Uncaught TypeError: array_rand(): Argument #1 ($array) must be of type array, int given in /in/HLH7g:5 Stack trace: #0 /in/HLH7g(5): array_rand(1, 3) #1 {main} thrown in /in/HLH7g on line 5
Process exited with code 255.
Output for 8.0.17, 8.1.6 - 8.1.7
Fatal error: Uncaught TypeError: array_rand(): Argument #1 ($array) must be of type array, int given in /in/HLH7g:5 Stack trace: #0 /in/HLH7g(5): array_rand(9, 3) #1 {main} thrown in /in/HLH7g on line 5
Process exited with code 255.
Output for 8.0.5, 8.0.9, 8.0.12 - 8.0.13, 8.0.19, 8.1.5
Fatal error: Uncaught TypeError: array_rand(): Argument #1 ($array) must be of type array, int given in /in/HLH7g:5 Stack trace: #0 /in/HLH7g(5): array_rand(5, 3) #1 {main} thrown in /in/HLH7g on line 5
Process exited with code 255.
Output for 8.0.6, 8.0.10, 8.0.14, 8.0.16, 8.1.4
Fatal error: Uncaught TypeError: array_rand(): Argument #1 ($array) must be of type array, int given in /in/HLH7g:5 Stack trace: #0 /in/HLH7g(5): array_rand(3, 3) #1 {main} thrown in /in/HLH7g on line 5
Process exited with code 255.
Output for 8.0.1, 8.1.3
Fatal error: Uncaught TypeError: array_rand(): Argument #1 ($array) must be of type array, int given in /in/HLH7g:5 Stack trace: #0 /in/HLH7g(5): array_rand(8, 3) #1 {main} thrown in /in/HLH7g on line 5
Process exited with code 255.
Output for 8.0.2 - 8.0.3, 8.0.15, 8.1.2
Fatal error: Uncaught TypeError: array_rand(): Argument #1 ($array) must be of type array, int given in /in/HLH7g:5 Stack trace: #0 /in/HLH7g(5): array_rand(6, 3) #1 {main} thrown in /in/HLH7g on line 5
Process exited with code 255.
Output for 8.0.8, 8.0.21, 8.1.0
Fatal error: Uncaught TypeError: array_rand(): Argument #1 ($array) must be of type array, int given in /in/HLH7g:5 Stack trace: #0 /in/HLH7g(5): array_rand(2, 3) #1 {main} thrown in /in/HLH7g on line 5
Process exited with code 255.
Output for 8.0.7, 8.0.11, 8.0.22
Fatal error: Uncaught TypeError: array_rand(): Argument #1 ($array) must be of type array, int given in /in/HLH7g:5 Stack trace: #0 /in/HLH7g(5): array_rand(7, 3) #1 {main} thrown in /in/HLH7g on line 5
Process exited with code 255.
Output for 7.4.0 - 7.4.30
Warning: array_rand() expects parameter 1 to be array, int given in /in/HLH7g on line 5 Warning: array_rand() expects parameter 1 to be array, int given in /in/HLH7g on line 5 Warning: array_rand() expects parameter 1 to be array, int given in /in/HLH7g on line 5 Warning: array_rand() expects parameter 1 to be array, int given in /in/HLH7g on line 5 Warning: array_rand() expects parameter 1 to be array, int given in /in/HLH7g on line 5 Warning: array_rand() expects parameter 1 to be array, int given in /in/HLH7g on line 5 Warning: array_rand() expects parameter 1 to be array, int given in /in/HLH7g on line 5 Warning: array_rand() expects parameter 1 to be array, int given in /in/HLH7g on line 5 Warning: array_rand() expects parameter 1 to be array, int given in /in/HLH7g on line 5

preferences:
19.24 ms | 424 KiB | 5 Q