You are here: Re: trivial arguments function « PHP Programming Language « IT news, forums, messages
Re: trivial arguments function

Posted by Jerry Stuckle on 07/13/06 15:52

jhullu@gmail.com wrote:
> hi all
>
> i've a function F as
>
> function F($arg1,$arg2,$arg3){
> ...
> }
>
> and a variable $args = "A,B,C"
>
> my goal is to call the function with the content of $args.
>
> if i call f($args) i call this function with 1 argument : an array, i
> wish call function as f(A,B,C)
>
> If Someone thinks this is possible... please give me the code ;))
>
> regards.
>

f($args[0]. $args[1], $args[2]);

Or -
f($arg1, $arg2=null, $arg3=null) {
if (is_array($arg1) && $arg2==null && $arg3 == null) {
if (count($arg1) == 3)
$arg2 = $arg1[1];
$arg3 = $arg1[2];
$arg1 = $arg1[0];
}
else {
echo "Insufficient number of parameters passed<br>\n";
exit();
}
}
... rest of stuff here
}

Of course you should do other checking to ensure you're passing 3
arguments in the array.


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

 

Navigation:

[Reply to this 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

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