|
Posted by Adam on 08/15/06 22:22
Thanks for your help so far... I had to type it from memory, so agree
that the "case 0:" was dead wrong!
The reason for using the multi arg input is twofold...
1. I am placing the vars into sprintf (to construct a MySQL query)
which is itself a variable arg function (hence why I don't think I can
use an array here).
2. Using an array just means I need a few extra lines of code to move
all of the random query bits into an intermediate array to stick into
the function. I would prefer to be able to list them in the function
call.
I am aware that there are other ways to do this, but I am aiming for an
ultra elegant solution. Maybe I'm being a bit pedantic about it!?! : )
Cheers again...
Adam
Rik wrote:
> 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
[Back to original message]
|