AW: [PHP] Re: How to use the fields of an array as individual parameter for a function
| From: | Christian Bartels | Date: | Tue, 04 Mar 2003 10:50:12 +0000 |
| Subject: | AW: [PHP] Re: How to use the fields of an array as individual parameter for a function | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-138071@lists.php.net to get a copy of this message | ||
Sure. But how do i return the array elements of $params as individual
parameters from processArray?
Any code? Would be great.
---
CB
-----Ursprüngliche Nachricht-----
Von: Patrick Schnegg [mailto:info@killersushi.ch]
Gesendet: Dienstag, 4. März 2003 11:40
An: php-general@lists.php.net
Betreff: Re: [PHP] Re: How to use the fields of an array as individual
parameter for a function
In this case, I would write a third function that processes the array for
passing it correctly to foo2. In a way that you will end up with something
like this:
$object = new foo2(processArray($params));
Have you thought about that?
"Christian Bartels" <mailinglisten@thebartels.de> wrote in message
news:000901c2e238$aea7be70$0300a8c0@cblaptop...
Yes, i thought about this already. But it is more work for me to do, 'cause
i would have to rewrite the constructors of several classes. Anyways i am
interested, whether this (pass the elements as variables) is possible in
php.
---
CB
-----Ursprüngliche Nachricht-----
Von: Patrick Schnegg [mailto:info@killersushi.ch]
Gesendet: Dienstag, 4. März 2003 11:11
An: php-general@lists.php.net
Betreff: [PHP] Re: How to use the fields of an array as individual parameter
for a function
Hi
Instead of worrying how to pass the individual parameters to foo2, simply
pass the whole array to it and process it within the function itself. Seems
more logical to me.
"Christian Bartels" <mailinglisten@thebartels.de> wrote in message
news:000201c2e233$c3ea0ae0$0300a8c0@cblaptop...
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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php