variable number of arguments pass by reference
Posted: Thu Apr 14, 2011 7:57 am
I want to create a function that I can pass a variable number of arguments by reference. For example if I want to apply some set of functions on a list of variables. In understand you can't really do this easily in PHP, but I saw some references to debug_backtrace, but I can't get it to work.
For example, I wrote:
function strip_all_tags() {
$stack = debug_backtrace();
$args = $stack[0]['args'];
for($i = 0; $i < count($args); $i++ ) {
$stack[0]['args'][$i] = strip_tags($args[$i]);
}
}
and then call:
strip_all_tags($a1, $a2, $a3);
Does anyone see what's wrong with this code? Any other suggestions?
m
For example, I wrote:
function strip_all_tags() {
$stack = debug_backtrace();
$args = $stack[0]['args'];
for($i = 0; $i < count($args); $i++ ) {
$stack[0]['args'][$i] = strip_tags($args[$i]);
}
}
and then call:
strip_all_tags($a1, $a2, $a3);
Does anyone see what's wrong with this code? Any other suggestions?
m