note 109988 deleted from function.func-get-args by aharvey

From: Date: Mon, 10 Sep 2012 01:17:52 +0000
Subject: note 109988 deleted from function.func-get-args by aharvey
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-190595@lists.php.net to get a copy of this message
Note Submitter: hall dot jared dot c at gmail dot com ---- I vote for a func_get_args_byRef() function in the next version of php. It would be beneficial for users to be able to create functions with variable arguments by reference like unset(). The only way I found to code a function like that which I can call with this code: <?php fixArrayKeys($arr1,$arr2,$arr3...) ?> is by using an ugly function declaration like so... <?php function fixArrayKeys(array &$arr1,array &$arr2=null,array &$arr3=null,array &$arr4=null,array &$arr5=null,array &$arr6=null,array &$arr7=null,array &$arr8=null,array &$arr9=null,array &$arr10=null) { $args = func_get_args(); if(count($args)>10) trigger_error("fixArrayKeys() can only except up to ten arguments", E_USER_ERROR); foreach($args as &$arg) { $Arr=array(); $i=0; foreach($arg as $val) { $Arr[$i]=$val; $i++; } $arg = $Arr; } return $newArray; } ?> you can also use debug_backtrace() to get a similar effect, but that seems like a lot of overhead just to get access to function arguments to me.

« previous php.notes (#190595) next »