關於數組的PHP問題。假設我們有兩個數組:結合並消除數組中的鍵值對
[first] => Array
(
[0] => users
[1] => posts
[2] => comments
)
[second] => Array
(
[users] => the_users
[posts] => the_posts
[comments] => the_comments
[options] => the_options
)
如何比較這兩個數組?意思是,我們如何在以某種方式組合它們(array_merge?)後檢查第一個數組中的值是否等於第二個數組中的鍵(array_flip?)。無論哪個值/密鑰對匹配,將它們從數組中移除。
基本上,最終結果將是兩個陣列組合,重複去除,並且唯一的索引將是:
[third] => Array
(
[options] => the_options
)
Ahhhhh! array_diff_key正是我想要的。非常感謝Vik。 – mousesports