Reply to Re: Variable Argument Function Calls

Your name:

Reply:


Posted by Jerry Stuckle on 08/15/06 11:47

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.
>
> At the moment, I have something along the lines of...
>
> ************************************************************
> function varargsfunction(){
>
> switch(func_num_args()){
> case 0:
> $value = function($inputargs[0]);
> break;
>
> case 1:
> $value = function($inputargs[0], $inputargs[1]);
> break;
>
> case 2:
> $value = function($inputargs[0], $inputargs[1], $inputargs[2]);
> break;
>
> etc.......
>
> }
>
> return otherfunction($value);
>
> }
> ************************************************************
>
> 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?
>
>
> Any help greatly appreciated!!
> Thanks in advance.
> Adam.
>

Why not let the functions take an array? That way you can have as many
or few parameters as you wish.


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация