Named Parameter In An Array

<?php

function greet($name, $title) {
    print "Hello, $title $name";
}

$args = ['title' => 'Mr.', 'name' => 'Doe'];
greet(...$args);

?>

It is possible to spread the arguments from an array to a functioncall. It is also possible to use the keys to name the arguments, and have them in any order in the array, just like named parameters.

It is possible since PHP 8.0, and was an unrelated error before.

See Also

PHP Error Messages

PHP Features

Last updated: 14 July 2026