我可以检查该值是否在“用户”内,但我无法检查该值是否在“页面”内 用户和页面如何工作?
$mypages = array(
'Pages' => array('pages' => array('add_page', 'edit_page')),
'Users' =>array('view_all_users', 'add_user'));
foreach($mypages as $keys => $key):
$display = in_array($_GET['page'], $key) ? "block" : "none";
echo '<ul style="display:'.$display.';"></ul>';
endforeach;
答案 0 :(得分:1)
应该这样做:
if(is_array($key) && array_key_exists('pages', $key)) {
$display = in_array($_GET['page'], $key['pages']) ? "block" : "none";
} else {
$display = in_array($_GET['page'], $key) ? "block" : "none";
}
答案 1 :(得分:0)
你能试试吗,
foreach($mypages as $keys => $key):
$display ='none';
if(!is_array($key)){
$display = in_array($_GET['page'], $key) ? "block" : "none";
}else{
$display = in_array($_GET['page'], $key['indexname']) ? "block" : "none";
}
echo '<ul style="display:'.$display.';"></ul>';
endforeach;