更新时间:2023-02-25 15:04:50
如果要将多维数组作为参数传递,只需传递名称为的子数组
If you want to pass a multi-dimensional array as a parameter, simply pass the child array with the name of the parent (container array).
因此,如果像
Array (
[pattern] =>
[status] => Array (
[0] => 0
[1] => 4
)
)
如果您想同时使用 status的两个元素
传递给函数,传递数组父级的名称。 (在这种情况下, param )
if you want both the elements of status
to be passed into the function,pass the name of the array parent. (in this case, param)
function foo($x)
{
echo "<pre>"; // just to make reading easy ;)
print_r($x);
}
函数foo()
显示传递给函数的内容,您可以使用该函数查看传递的内容。
The function foo()
displays the contents passed into the function which you can use to see what's being passed.
诸如 foo($ param ['status'])
之类的东西>
给出了这个:
so things like foo($param['status'])
gives this :
Array( [0] => 0 [1]=> 4 )
以及 foo($ param ['status'] [1])
给出了以下内容: 4