Re: Variable number of parameters
| From: | Daniel Brown | Date: | Tue, 05 Aug 2008 13:58:48 +0000 |
| Subject: | Re: Variable number of parameters | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-277723@lists.php.net to get a copy of this message | ||
On Tue, Aug 5, 2008 at 1:40 AM, Philip Thompson <philthathril@gmail.com> wrote:
> Is it possible to grab a variable number of parameters and send the
> appropriate amount to another function?
You can predefine function parameters:
<?php
function example($line1,$line2="There is no line 2.") {
echo $line1."\n";
echo $line2."\n";
}
example("This is a test.","This is another test.");
/*
Returns:
This is a test.
This is another test.
*/
example("This is a third test.");
/*
Returns:
This is a third test.
There is no line 2.
*/
?>
.... but more likely, you're looking for func_get_args().
http://php.net/func_get_args
--
</Daniel P. Brown>
More full-root dedicated server packages:
Intel 2.4GHz/60GB/512MB/2TB $49.99/mo.
Intel 3.06GHz/80GB/1GB/2TB $59.99/mo.
Intel 2.4GHz/320/GB/1GB/3TB $74.99/mo.
Dedicated servers, VPS, and hosting from $2.50/mo.