variable num of function args

From: Date: Tue, 03 Dec 2002 13:31:54 +0000
Subject: variable num of function args
Groups: php.general 
Request: Send a blank email to php-general+get-126844@lists.php.net to get a copy of this message
hi all, is it possible to somehow have a function which takes a variable number of arguments (with some kind of key association) which can then be converted to variables? i am sick of continually having to go back and add empty parameters to functions in use. an example would be.. function test1() { extract(func_arg_keys()); print $this; } test1($test = 1, $this = 2); // output 2 i know something similar can be done like this... function test2() { extract($arr); print $this; } test2($arr = array( "test" => 1, "this" => 2 )); // output 2 is there another ... better or cleaner way? having something like this inbuilt into php would appear to be an excellent to allow functions to easily expand without having to go revisit already used instances of the function many thanks christian ps sorry if this has been discussed before

« previous php.general (#126844) next »