|
Posted by Rik on 08/15/06 12:21
Jerry Stuckle wrote:
> Adam wrote:
>> Hey,
>>
>> Just a quick appeal for suggestions re some code, able to pass
>> varying numbers of arguments...
>>
>> I have a function which can accept varying numbers of arguments. It
>> in turn calls a function whose argument list can vary in length.
<snip code>
>> It works fine, but I am obviously restricted by the length of my case
>> statement. Also, as you can see it's not a very pretty solution!!
>>
>> Is there a way to dynamically build the argument list such that it
>> does not require me to write out every possible case into a big
>> switch statement?
>
> Why not let the functions take an array? That way you can have as
> many or few parameters as you wish.
While offcourse a better idea, one might want to adress an already existing
PHP function, where the behaviour cannot be altered easily. But in that
case, a simple call_user_func_array() in the code itself should suffice,
instead of making it a different function.
We might have better insight if the OP could explain what the function
should actually do.
Grtz,
--
Rik Wasmus
Navigation:
[Reply to this message]
|