Ok, but how do i pass the vars to the second function (foo2)? There is not a fixed number of parameters (and so fields in the $params array).
--- Gruß CB -----Ursprüngliche Nachricht----- Von: Jason Paschal [mailto:[EMAIL PROTECTED] Gesendet: Dienstag, 4. März 2003 11:03 An: [EMAIL PROTECTED] Betreff: Re: [PHP] How to use the fields of an array as individual parameter for a function there are all sorts of ways to get elements out of arrays. here's one: if i don't know how many elements are in the array: $numinarray = count($array); //gives me the number of elements in array for ($i=0;$i<$numinarray;$i++) { $element = $array[$i]; echo "$element is in the array."; } there's also a for each loop, but the syntax escapes me >From: "Christian Bartels" <[EMAIL PROTECTED]> >To: <[EMAIL PROTECTED]> >Subject: [PHP] How to use the fields of an array as individual >parameter >for a function >Date: Tue, 4 Mar 2003 10:52:26 +0100 > >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 > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php > _________________________________________________________________ Add photos to your e-mail with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=features/featuredemail -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php