PASSING A "VARIABLE-LENGTH ARGUMENT LIST OF REFERENCES" TO A FUNCTION
As of PHP 5, Call-time pass-by-reference has been deprecated, this represents no problem in most cases, since instead of calling a function like this:
myfunction($arg1, &$arg2, &$arg3);
you can call it
myfunction($arg1, $arg2, $arg3);
provided you have defined your function as
function myfuncion($a1, &$a2, &$a3) { // so &$a2 and &$a3 are
// declared to be refs.
... <function-code>
}
However, what happens if you wanted to pass an undefined number of references, i.e., something like:
myfunction(&$arg1, &$arg2, ..., &$arg-n);?
This doesn't work in PHP 5 anymore.
In the following code I tried to amend this by using the
array() language-construct as the actual argument in the
call to the function.
<?php
function aa ($A) {
foreach ($A as &$x) {
$x += 2;
}
}
$x = 1; $y = 2; $z = 3;
aa(array(&$x, &$y, &$z));
echo "--$x--$y--$z--\n";
?>
I hope this is useful.
Sergio.