Array_diff_assoc – Difference set of computed arrays with index check

Description:

array_diff_assoc ( array $array1 , array $array2 , array $... =)? : arraCopy the code

Array_diff_assoc () returns an array containing all values that are in Array1 but not in any other parameter array. Note that unlike array_diff(), key names are also used for comparison.

Parameters:

Array1: Compare from this array

Array2: The array to be compared

. : More arrays to compare

The return value:

Returns an array containing all values that do not exist in any other array in Array1.

Example:

Example 1

<? php $array1 = array("a" => "green", "b" => "brown", "c" => "blue", "red"); $array2 = array("a" => "green", "yellow", "red"); $result = array_diff_assoc($array1, $array2); print_r($result); ? > output: Array ([b] = > brown [c] = > blue [0] = > red)Copy the code

Example 2

<? php $array1 = array(0, 1, 2); $array2 = array("00", "01", "2"); $result = array_diff_assoc($array1, $array2); print_r($result); ? Array([0] => 0 [1] => 1)Copy the code