我有 2 个数组,我需要查找数组 1 中的值之一是否与数组 2(多维数组)中的值之一匹配。我还需要检查数组一中的值是否在数组二中的特定键中,作为“权限”键的“主”键也可能包含该值。
这是数组一:
Array
(
[0] => 17
[1] => 6
[2] => 3
[3] => 2
)
和数组二 [实际上为了便于阅读而略微截断]:
Array
(
[modAccessResourceGroup] => Array
(
[3] => Array
(
[0] => Array
(
[principal] => 0
[authority] => 9999
[policy] => Array
(
[load] => 1
)
)
[1] => Array
(
[principal] => 2
[authority] => 10
[policy] => Array
(
[add_children] => 1
[create] => 1
[copy] => 1
[delete] => 1
[list] => 1
[load] => 1
[move] => 1
[publish] => 1
[remove] => 1
[save] => 1
[steal_lock] => 1
[undelete] => 1
[unpublish] => 1
[view] => 1
)
)
.... truncated ....
[13] => Array
(
[principal] => 16
[authority] => 9999
[policy] => Array
(
[load] => 1
)
)
)
[8] => Array
(
[0] => Array
(
[principal] => 0
[authority] => 9999
[policy] => Array
(
[load] => 1
)
)
[1] => Array
(
[principal] => 1
[authority] => 9999
[policy] => Array
(
[add_children] => 1
[create] => 1
[copy] => 1
[delete] => 1
[list] => 1
[load] => 1
[move] => 1
[publish] => 1
[remove] => 1
[save] => 1
[steal_lock] => 1
[undelete] => 1
[unpublish] => 1
[view] => 1
)
)
[2] => Array
(
[principal] => 22
[authority] => 9999
[policy] => Array
(
[add_children] => 1
[create] => 1
[copy] => 1
[delete] => 1
[list] => 1
[load] => 1
[move] => 1
[publish] => 1
[remove] => 1
[save] => 1
[steal_lock] => 1
[undelete] => 1
[unpublish] => 1
[view] => 1
)
)
)
)
)
我正在使用一系列 foreach(){foreach(){foreach(){}}} 但它看起来非常混乱且效率低下。在解决这个问题时遇到了一些麻烦。有任何想法吗?