note 40967 added to functions.arguments
| From: | heckATfasDOTharvardDOTedu at rn2 dot php dot net | Date: | Wed, 24 Mar 2004 22:49:49 +0000 |
| Subject: | note 40967 added to functions.arguments | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-67129@lists.php.net to get a copy of this message | ||
I have some functions that I'd like to be able to pass arguments two ways: Either as an
argument list of variable length (e.g. func(1, 2, 3, 4)) or as an array (e.g., func(array(1,2,3,4)).
Only the latter can be constructed on the fly (e.g., func($ar)), but the syntax of the former can be
neater.
The way to do it is to begin the function as follows:
$args = func_get_args();
if (is_array ($args[0]))
$args = $args[0];
Then one can just use $args as the list of arguments.
----
Manual Page -- http://www.php.net/manual/en/functions.arguments.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+40967
Delete -- http://master.php.net/manage/user-notes.php?action=delete+40967&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+40967&report=yes
Search -- http://master.php.net/manage/user-notes.php