2017-01-16 100 views
1

我有以下父數組,我試圖從另一個數組中找到與此父級相比缺少的元素。需要與模塊和動作相比較是相同的。在多維數組中搜索

Parent 
(
[0] => Array 
    (
     [label] => Masters 
     [module] => masters 
     [action] => unit_index 
    ) 

[1] => Array 
    (
     [label] => Appointments 
     [module] => appointments 
     [action] => appointment_index 
    ) 

[2] => Array 
    (
     [label] => Transactions 
     [module] => transactions 
     [action] => 
    ) 

[3] => Array 
    (
     [label] => Reports 
     [module] => p_reports 
     [action] => ds_index 
    ) 

我想這是從父缺少以下兒童陣列

Array 
(
[masters] => Array 
    (
     [label] => Masters 
     [action] => unit_index 
     [module] => masters 
    ) 

[transactions] => Array 
    (
     [label] => Transactions 
     [action] => 
     [module] => transactions 
) 
[p_reports] => Array 
    (
     [label] => Reports 
     [action] => ds_index 
     [module] => p_reports 
    ) 

)在

我試着用in_array搜索,並使用一些項目數組中的遞歸版本,但我不能使用多個鍵進行搜索。

+0

什麼是烏爾預期產出? – slier

+0

的其中之一中不存在這兩種 陣列 ( [標號] =>約會 [模塊] =>約會 [動作] => appointment_index ) – user5349142

回答

0

check this page

PHP 4> = 4.0.5,PHP 5,PHP 7)

array_search - 檢索給定值的數組,並返回所述第一相應的鍵,如果成功