Returns an array of common elements for the intersection (only the array is worth comparing), the ARRAY_INTERSECT_ASSOC () function is binding the key and value, and the Array_intersect_key () function compares the key values of two arrays. Returns an array of key-value intersections.
But the actual application also encountered some small problems, is as follows:
Instance:
Copy CodeThe code is as follows:
$array = Array ("Red" and "red", "green" = "red4", "Red15" = "Red",7=> "level", "Width" = "Red", "azzzz1" = > "Art", "Peak" =>158);
$array 1 = Array ("Red" = "Red2", "Greena" and "Red", "Red15" and "Red",7=> "level", "Width" = "Red", "azzzz" = > "Art", "Peak" =>158);
$num = Array_intersect ($array, $array 1);
Print_r ($num);
echo "
";
$num = Array_intersect_assoc ($array, $array 1);
Print_r ($num);
echo "
";
$num = Array_intersect_key ($array, $array 1);
Print_r ($num);
?>
Operation Result:
Copy CodeThe code is as follows:
Array ([Red] = red [Red15] + red [7] = level [Width] = red [AZZZZ1] = art [peak] + 158)
Array ([Red15] = red [7] = level [Width] + red [peak] = 158)
Array ([Red] = red [Red15] + red [7] = level [Width] + red [peak] = 158)
Summarize:
The comparison of the 1.array_intersect () function only compares the values of the array, and there is a "red" when compared with "red" and "Red2", whereas the "Red2" is not returned;
The 2.ARRAY_INTERSECT_ASSOC () function compares the value of an array with a key value, and there is no array_intersect, which is appropriate for a more rigorous comparison;
The 3.array_intersect_key () function is useful for comparing the intersection of two array key values, returning not only the key value, but the key value and the corresponding array value.
http://www.bkjia.com/PHPjc/323458.html www.bkjia.com true http://www.bkjia.com/PHPjc/323458.html techarticle returns an array of common elements for the intersection (just the array is worth comparing), the ARRAY_INTERSECT_ASSOC () function is binding the key value and the value, and comparing the intersection part, the Array_intersect_key () function is ...