note 40967 deleted from functions.arguments by cmb
| From: | cmb@php.net | Date: | Sun, 10 Nov 2019 12:57:39 +0000 |
| Subject: | note 40967 deleted from functions.arguments by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-213017@lists.php.net to get a copy of this message | ||
Note Submitter: heck AT fas DOT harvard DOT edu
----
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.