Re: AW: [PHP] How to use the fields of an array as individual parameter for a function
| From: | Jason Wong | Date: | Tue, 04 Mar 2003 13:14:49 +0000 |
| Subject: | Re: AW: [PHP] 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-138094@lists.php.net to get a copy of this message | ||
On Tuesday 04 March 2003 18:24, Christian Bartels wrote:
> 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).
You can do something along these lines:
function doo($args) {
// these are the default values for your args
$element_name = '';
$method = 'post';
$upload = FALSE;
$return = FALSE;
if (is_array($args)) {
extract($args);
}
// You can also check whether a required parameter was given:
if (!isset($required_parameter)) { echo "Error blah blah blah ..."; }
... your code
}
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
Those lovable Brits department:
They also have trouble pronouncing `vitamin'.
*/