在 PHP 中将数组作为参数传递,而不是数组 [英] Passing an Array as Arguments, not an Array, in PHP

查看:38
本文介绍了在 PHP 中将数组作为参数传递,而不是数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎记得在 PHP 中有一种方法可以将数组作为函数的参数列表传递,将数组解引用为标准的 func($arg1, $arg2) 方式.但现在我不知道该怎么做.我记得通过引用传递的方式,如何glob"传入参数......但不记得如何将数组从参数列表中删除.

I seem to remember that in PHP there is a way to pass an array as a list of arguments for a function, dereferencing the array into the standard func($arg1, $arg2) manner. But now I'm lost on how to do it. I recall the manner of passing by reference, how to "glob" incoming parameters ... but not how to de-list the array into a list of arguments.

它可能和 func(&$myArgs) 一样简单,但我很确定不是这样.但是,遗憾的是,php.net 手册到目前为止还没有透露任何内容.并不是说我在过去一年左右的时间里不得不使用这个特殊功能.

It may be as simple as func(&$myArgs), but I'm pretty sure that isn't it. But, sadly, the php.net manual hasn't divulged anything so far. Not that I've had to use this particular feature for the last year or so.

推荐答案

http://www.php.net/manual/en/function.call-user-func-array.php

call_user_func_array('func',$myArgs);

这篇关于在 PHP 中将数组作为参数传递,而不是数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆