我正在尝试获取提供第二级数组值的第一级数组的键,但它不起作用。我在这里做错了什么?非常感谢。
$linksUrls = array(
'index'=>array('ar'=>'inicio','en'=>'home'),
'portfolio'=>array('ar'=>'portfolio-de-fotografia/casas','en'=>'photography-portfolio/homes'),
'contacto'=>array('ar'=>'contacto','en'=>'contact')
);
/* This one will not work */
print_r(array_keys($linksUrls,'contact'));
/* This one will */
function search($arr, $srch){
foreach($arr as $key => $val){
foreach($val as $k => $v){
if ($v == $srch){ echo $key; }
}
}
}
search($linksUrls, "contact");
感谢凯尔...