| This article describes how to find the intersection of correlated arrays in a php array. For more information, see. The php function array_intersect_assoc () is basically the same as array_intersect (), except that the array key is also considered during comparison. Therefore, only key/value pairs that appear in the first array and also appear in all other input arrays are returned to the result array. The format is as follows: array array_intersect_assoc (array array1, array array2 [, arrayN…]) In this example, all key/value pairs that appear in the $ fruit1 array and $ fruit2 and $ fruit3 are returned:
"Apple", "yellow" => "Banana", "orange" => "Orange"); $ fruit2 = array ("yellow" => "Pear ", "red" => "Apple", "purple" => "Grape"); $ fruit3 = array ("green" => "Watermelon ", "orange" => "Orange", "red" => "Apple"); $ intersection = array_intersect_assoc ($ fruit1, $ fruit2, $ fruit3); print_r ($ intersection ); // by bbs.it-home.org // output // Array ([red] => Apple)?> |