Is it possible to convert an array to a list of elements without using list?
是否可以在不使用列表的情况下将数组转换为元素列表?
this works well
这很好用
list($arg_a,$arg_b) = array($foo,$bar);
myfunction($arg_a,$arg_b);
but I'm looking for something similar to that:
但我正在寻找类似的东西:
$array = array($foo,$bar);
myfunction(php_builtin_function(array($foo,$bar)));
obviusly I can't edit that function!
显然,我无法编辑该功能!
function myfunction($param_a,$param_b){
...
}
1 个解决方案
#1
1
As mentioned in comments, here's what you need:
如评论中所述,这是您需要的:
call_user_func_array('myfunction', php_builtin_function(array($foo,bar)));
文件
That said, it would be more readable to use list
:
也就是说,使用list会更具可读性:
$result = php_builtin_function(array($foo,$bar));
list($arg_a, $arg_b) = $result;
myfunction($arg_a, $arg_b);
#1
1
As mentioned in comments, here's what you need:
如评论中所述,这是您需要的:
call_user_func_array('myfunction', php_builtin_function(array($foo,bar)));
文件
That said, it would be more readable to use list
:
也就是说,使用list会更具可读性:
$result = php_builtin_function(array($foo,$bar));
list($arg_a, $arg_b) = $result;
myfunction($arg_a, $arg_b);