返回鍵我有一個這樣的陣列:找到匹配的陣列和使用PHP
Array
(
[2] => Array
(
[0] => name2 surname
[1] => [email protected]
[2] => 834502034
[3] => image url3
)
[3] => Array
(
[0] => name3 surname
[1] => [email protected]
[2] => 7648484886
[3] => image url3
)
[0] => Array
(
[0] => name0 surname
[1] => [email protected]
[2] => 56783658658
[3] => image url0
)
[1] => Array
(
[0] => name1 surname
[1] => [email protected]
[2] => 7648484886
[3] => image url1
)
)
你會通知,某些值是相同的,並且可能僅具有在值的單個差別。
我需要找出另一個單個數組是否與子數組上的任何數組匹配並返回鍵。
數組我會對陣並不多層面:
Array
(
[0] => name1 surname
[1] => [email protected]
[2] => 7648484886
[3] => image url1
)
如何才能知道如果我的單陣列主陣列中找到並返回KEY? 我曾嘗試使用array_diff_uassoc和一個回調函數來返回非匹配鍵=>數組,我想我可以匹配兩個結果的計數來查看是否有差異,但我仍然需要匹配數組的鍵。我正在比較的數組始終具有確切的值[0],[1],[2]和[3]。
你可能想看看array_filter()函數和array_walk()函數。看到這裏http://pt.php.net/manual/en/function.array-filter.php在這裏http://pt.php.net/manual/en/function.array-walk.php – bodi0