4.array_diff_assoc()
在前一个函数的基础上,不仅需要匹配值还要匹配键。
例子:
<?php $array1 = array ("a" => "green", "b" => "brown", "c" => "blue", "red"); $array2 = array ("a" => "green", "yellow", "red"); $result = array_diff_assoc($array1, $array2); ?> |
上例将输出:
Array ( [b] => brown [c] => blue [0] => red ) |