例如,我有以下代码:
$pars = array('foo'=>array(1, 2, 3, 4));
function x($par){
// how do i get array key from $par, so it will print/return 'foo'
}
x($pars['foo']);
当我调用函数x($pars['foo'])
答案 0 :(得分:0)
尝试这样,
function x($par){
foreach ($par as $key => $value)
{
//you can get key here
}
}