-1

我可以检查该值是否在“用户”内,但我无法检查该值是否在“页面”内 它如何对用户和页面起作用?

$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;
4

2 回答 2

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";
}
于 2013-11-09T09:41:39.650 回答
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;
于 2013-11-09T09:47:12.143 回答