In PHP, we can write functions that accept a variable number of arguments — meaning, we don’t have to know how many values will be passed in when we define the function. We can do that by using ... operator in front of the function parameter. The variadic operator ... allows you to capture any number of arguments into an array.

Syntax:

function functionName(...$variableName) {
    // $variableName is an array containing all passed arguments
}

Example:

function SayWelcome(...$users) {
    $result = "";
    foreach( $users as $index=>$user ){
        $result .= "Welcome $user.";
        if( $index != count($users) -1 ){
            $result .= "\n";
        }
    }
    return $result;
}

echo SayWelcome("Virat", "Williams", "Messi");

Output: