note 73215 deleted from function.func-get-args by peehaa

From: Date: Mon, 08 Apr 2019 06:11:30 +0000
Subject: note 73215 deleted from function.func-get-args by peehaa
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-210548@lists.php.net to get a copy of this message
Note Submitter: rafagd at gmail dot com ---- Sometimes, you may need to dynamic set and get of args... This function merge array args, so you can dynamic set some args by sending an array arg. <?php function dynamicArgs(/*$arg1, $arg2...$argN*/) { $args = func_get_args(); $num = func_num_args(); for ($i = 1; $i < $num; $i++) { $args[0] = array_merge((array) $args[0], (array) $args[$i]); } return $args[0]; } var_dump(dynamicArgs('a',array('b','c'),'d',1); ?> This should output like: array(5) { [0]=> string(1) "a" [1]=> string(1) "b" [2]=> string(1) "c" [3]=> string(1) "d" [4]=> int(1) }

« previous php.notes (#210548) next »