Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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: 10 September 2026