variable number of arguments pass by reference

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mluria
Forum Newbie
Posts: 1
Joined: Thu Apr 14, 2011 7:41 am

variable number of arguments pass by reference

Post by mluria »

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
Post Reply