Re: Variable number of parameters

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Aug 5, 2008 at 1:40 AM, Philip Thompson <philthathril@xxxxxxxxx> 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.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux