3v4l.org

run code in 300+ PHP versions simultaneously
<?php $foo = [ 'biz' => 'bar', 'whiz' => 'whang', ]; array_unshift($foo['rocket'], 'snaps'); var_export($foo);
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.26, 8.4.1 - 8.4.13
Fatal error: Uncaught TypeError: array_unshift(): Argument #1 ($array) must be of type array, null given in /in/upDAK:7 Stack trace: #0 /in/upDAK(7): array_unshift(NULL, 'snaps') #1 {main} thrown in /in/upDAK on line 7
Process exited with code 255.
Output for 5.6.38, 7.1.0 - 7.1.22, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33
Warning: array_unshift() expects parameter 1 to be array, null given in /in/upDAK on line 7 array ( 'biz' => 'bar', 'whiz' => 'whang', 'rocket' => NULL, )

preferences:
143.75 ms | 408 KiB | 5 Q