php - Call function with unlimited params -
this question has answer here:
- unlimited arguments php function? 4 answers
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
Post a Comment