3v4l.org

run code in 300+ PHP versions simultaneously
<?php function zeroOneTwo($one, $two, $three) { return [$one, $two, $three]; } function abc($b, $c, $a) { return [$a, $b, $c]; } $numericKeyedArray = [4,5,6]; var_export(abc(...$numericKeyedArray)); echo "\n---\n"; var_export(zeroOneTwo(...$numericKeyedArray)); echo "\n===\n"; $nonNumericKeyedArray = ['c' => 'sea', 'a' => 'A', 'b' => 'bee']; echo "\n---\n"; var_export(abc(...$nonNumericKeyedArray)); echo "\n===\n"; var_export(zeroOneTwo(...$nonNumericKeyedArray));
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.27, 8.4.1 - 8.4.14
array ( 0 => 6, 1 => 4, 2 => 5, ) --- array ( 0 => 4, 1 => 5, 2 => 6, ) === --- array ( 0 => 'A', 1 => 'bee', 2 => 'sea', ) === Fatal error: Uncaught Error: Unknown named parameter $c in /in/NYufH:21 Stack trace: #0 {main} thrown in /in/NYufH on line 21
Process exited with code 255.
Output for 7.4.0 - 7.4.33
array ( 0 => 6, 1 => 4, 2 => 5, ) --- array ( 0 => 4, 1 => 5, 2 => 6, ) === --- Fatal error: Uncaught Error: Cannot unpack array with string keys in /in/NYufH:19 Stack trace: #0 {main} thrown in /in/NYufH on line 19
Process exited with code 255.

preferences:
132.24 ms | 407 KiB | 5 Q