note 73215 added to function.func-get-args

From: Date: Tue, 13 Feb 2007 16:53:08 +0000
Subject: note 73215 added to function.func-get-args
Groups: php.notes 
Request: Send a blank email to php-notes+get-123326@lists.php.net to get a copy of this message
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. <? 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) } ---- Server IP: 69.147.83.197 Probable Submitter: 201.58.122.61 ---- Manual Page -- http://www.php.net/manual/en/function.func-get-args.php Edit -- https://master.php.net/note/edit/73215 Del: integrated -- https://master.php.net/note/delete/73215/integrated Del: useless -- https://master.php.net/note/delete/73215/useless Del: bad code -- https://master.php.net/note/delete/73215/bad+code Del: spam -- https://master.php.net/note/delete/73215/spam Del: non-english -- https://master.php.net/note/delete/73215/non-english Del: in docs -- https://master.php.net/note/delete/73215/in+docs Del: other reasons-- https://master.php.net/note/delete/73215 Reject -- https://master.php.net/note/reject/73215 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#123326) next »