How to use the fields of an array as individual parameter for a function

From: Date: Tue, 04 Mar 2003 09:52:26 +0000
Subject: How to use the fields of an array as individual parameter for a function
Groups: php.general 
Request: Send a blank email to php-general+get-138063@lists.php.net to get a copy of this message
Hello! I'm new here on the list. I hope you can help me! :) I have a function foo1 which has a parameter $params. In the function i want to pass $params to another function foo2. if $params is an array the elements should be passed to foo2 as individual parameters. Is this possible? How do i do that? Example: function foo1($params) { if (is_array($params)) { $object = new foo2(GET THE ELEMENTS OF $params AS INDIVIDUAL PARAMETERS HERE); } else { $object = new foo2($params); } } So when this is called: foo1(array('blue', 'red', 'green')); In foo1 foo2 should be called like this: foo2('blue', 'red', 'green'); Is this possible? Thanks for any help! (sorry about my english ;-)) --- CB

« previous php.general (#138063) next »