You are here: Re: Passing variable number of arguments from array to function with call_user_func()? « PHP Programming Language « IT news, forums, messages
Re: Passing variable number of arguments from array to function with call_user_func()?

Posted by C. on 08/13/07 12:21

On 13 Aug, 01:42, rob <r...@rawb.net> wrote:
>
> For example, if I have the following array:
>
> $list = array('sky' => 'blue', 'grass' => 'green');
> $list = array_values($list);
>
> I'd like to pass the two values in $list to a function that has two
> arguments, i.e:
>
> function color($sky, $grass) { }
>

call_user_func('color', $list);

function color()
{
$params = func_get_args();
....

But it's much cleaner to do this:

color($list);

function color($list) // expect an array as input
{
....

Which eliminates the positional problems which are exacerbated by
variable argument parsing.

C.

 

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

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