3v4l.org

run code in 300+ PHP versions simultaneously
<?php function foo(...$args) { var_dump($args); } foo(...[3 => 'a', 4 => 'b']); foo(...['a' => 'a', 'b' => 'b']);
Output for 8.0.0 - 8.0.10, 8.1rc1
array(2) { [0]=> string(1) "a" [1]=> string(1) "b" } array(2) { ["a"]=> string(1) "a" ["b"]=> string(1) "b" }
Output for 7.3.0 - 7.3.30, 7.4.0 - 7.4.23
array(2) { [0]=> string(1) "a" [1]=> string(1) "b" } Fatal error: Uncaught Error: Cannot unpack array with string keys in /in/iiYNL:8 Stack trace: #0 {main} thrown in /in/iiYNL on line 8
Process exited with code 255.

preferences:
18.59 ms | 460 KiB | 5 Q