php - Call function with unlimited params -


this question has answer here:

i have array:

array (    foo => 1,    bar => 2    ....... ) 

and function unlimit params, need call function this:

$x = myfunc(array('foo'=>1), array('bar'=>2),...); 

is possible without eval?

use func_get_args.

test code:

function sum() {     $sum = 0;     foreach(func_get_args() $arg)         $sum += $arg;     return $sum; }  echo sum(1,2,3,4,5,6,7,8,9,10); 

output:

55 

Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -