3v4l.org

run code in 300+ PHP versions simultaneously
<?php $list = [1, 2, 3, 4, 5, 6, 7, 8, 9]; $key = array_rand($list, 3); echo $list[$key]; ?>
Output for 8.0.1 - 8.0.22, 8.1.0 - 8.1.9
Fatal error: Uncaught TypeError: Illegal offset type in /in/PeroX:5 Stack trace: #0 {main} thrown in /in/PeroX on line 5
Process exited with code 255.
Output for 7.4.0 - 7.4.30
Warning: Illegal offset type in /in/PeroX on line 5

preferences:
21.39 ms | 410 KiB | 5 Q