Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有数组:
Array ( foo => 1, bar => 2 ....... )
并且具有无限参数的功能,现在我需要像这样调用函数:
$x = myFunc(array('foo'=>1), array('bar'=>2),...);
没有eval有可能吗?
使用func_get_args.
func_get_args
测试代码:
function sum() { $sum = 0; foreach(func_get_args() as $arg) $sum += $arg; return $sum; } echo sum(1,2,3,4,5,6,7,8,9,10);
输出:
55