2016-04-11 116 views
-1

這是陣列輸出如何獲取數組值,如果特定值在整個數組值匹配

Array (
    [0] => Array (
    [menu_id] => 1 
    [menu_name] => Dashboard 
    [read_or_edit] => E 
    [active_inactive] => A) 
    [1] => Array (
    [menu_id] => 2 
    [menu_name] => Orders-View Orders 
    [read_or_edit] => E [active_inactive] => A) 
    [2] => Array (
    [menu_id] => 3 
    [menu_name] => Orders-Sales Report 
    [read_or_edit] => E 
    [active_inactive] => A) 
) 

在我剛保存儀表盤插入變量一樣$pagename=Dashboard,與我使用數組搜索後我的$pagename轉換爲整個數組值。

現在我怎樣才能使用儀表板匹配來獲得特定的第零個關鍵數組值?

+0

歡迎StackOverflow的,我已經重新格式化您的代碼塊,因爲它是在同一行,基本上不可讀,請查看[鏈接編輯幫助(http://stackoverflow.com/editing-help)更多有關格式化您的帖子的信息。 –

回答

0
$fine_data=Array (
    [0] => Array (
    [menu_id] => 1 
    [menu_name] => Dashboard 
    [read_or_edit] => E 
    [active_inactive] => A) 
    [1] => Array (
    [menu_id] => 2 
    [menu_name] => Orders-View Orders 
    [read_or_edit] => E [active_inactive] => A) 
    [2] => Array (
    [menu_id] => 3 
    [menu_name] => Orders-Sales Report 
    [read_or_edit] => E 
    [active_inactive] => A) 
) 

$key = array_search($page_name, array_column($fine_data, 'menu_name')); 
foreach ($fine_data as $key_final => $value) { 
if($key_final==$key) 
{ 
$acess=$value->read_or_edit; 
//youo can get all value like an above 
} 
} 
echo $acess;