PHP array_uintersect_assoc() function

PHP array_uintersect() function
PHP array_uintersect_uassoc() function

The array_uintersect_assoc function returns an array that contains the keys and values that are present in array 1 and the following arrays after it.

It uses a built-in method to compare the keys and a user-defined function to compare the values.

What is the syntax of the array_uintersect_assoc function in PHP?

array_uintersect_assoc(array1, array2, array3, ..., myfunction)
ParametersDetails
array1The first array to compare with other arrays – required
array2Second array to make a comparison against- required
array3, ...Further arrays to compare against – optional
user-defined functionUser-defined function to compare the keys of arrays. The function must return an integer <, = or > than 0 if the first argument is <, + or > than the second argument.
array_uintersect_assoc function in PHP

Example of array_uintersect_assoc function

Example 1. Compare keys and values of two arrays using a built-in function for the comparison of keys and a user-defined function for the comparison of values and return the matches.

<?php
function my_function($x,$y)
{
if ($x==$y)
  {
  return 0;
  }
  return ($x>$y)?1:-1;
}

$array_1=array("a"=>"R","b"=>"G","c"=>"B");
$array_2=array("a"=>"R","b"=>"B","c"=>"G");

$result=array_uintersect_assoc($array_1,$array_2,"my_function");
print_r($result);
?>
PHP array_uintersect() function
PHP array_uintersect_uassoc() function
en English
X
Scroll to Top