如果我像这样使用数组作为函数参数:
function test($arg = array('name'=>'','position'=>'')){
echo $arg['name'];
}
如何使用此函数填充数组参数?
答案 0 :(得分:0)
每当你调用这样的函数时:
test(array('name'=>'username', 'position'=>'director'));
您拥有的function test($arg = array('name','position'))
是默认的参数值。
答案 1 :(得分:0)
用数组调用它:
$name = "Fred";
$position = "President";
test(array('name' => $name, 'position' => $position));