Q:

how to pass unlimited arguments by reference in php

I have php function that has an unlimited number of args which I am getting from func_get_args(). I have some operations with arguments (changing string or doing something) and I want this to be like a passing argument by reference. is it possible?
example:
$test = 'foo';
$test2 = 'bar';

function test(){
    $args = func_get_args();
    foreach($args as $arg)
        $arg .= 'baz';
}

test($test, $test2);

A:

Since PHP-5.6 you can use a variadic reference:
function test(&...$args) {
    foreach ($args as &$arg) {
        $arg .= 'baz';
    }
}

A:

As answered in PHP: variable-length argument list by reference?, there is no way in PHP to combine variable-length and pass by reference function arguments. Instead, the linked answer uses a hack of declaring 100 &argxs, then using get_num_args() to figure out how many were actually used. Congratulations, you found a particularly hard corner in PHP ;)

A:

I highly doubt that's possible, but I do know one way you could get what you want:
function test(&$args) {
    foreach ($args as $arg) {
        $arg .= 'baz';
    }
}

test(array(&$test, &$test2));

