How to use array uintesect assoc in PHP
In this article, I will explain how the array_uintesect_assoc() function can be used in PHP.
array_uintesect_assoc() function in PHP
-
The array_uintesect_assoc() function is used to compares two or more arrays, both in a built in function and in a user-made function.
-
The array_uintesect_assoc() function returns an array containing the elements from the first array.
-
In array_uintesect_assoc() function user-define function compares the values, and returns a numeric value.
-
In array_uintesect_assoc() function, the key is used for comparison in the built-in function.
-
In array_uintesect_assoc() function, the value is used for comparison in the user-made function.
Syntax
array_uintesect_assoc(array1,array2,array3....,function) |
Parameter
-
array1 array1 is required parameter. The first array is the array which will be compared with other arrays.
-
array2 array2 is required parameter. An array to be compared with the first array.
-
array3 array3 is optional parameter. An array to be compared with the first array.
-
function function is required parameter. The function define by user.
Example
The following example show to how the array_uintesect_assoc() function can be used in PHP.
<html>
<body>
<h3 style="color: royalblue;">array_uintersect_assoc() function example in PHP</h3>
<?php
function mydemo($s1,$s2)
{
if ($s1===$s2)
{
return 0;
}
return 1;
}
$a1=array("a"=>"Computer","b"=>"Mouse","c"=>"CPU");
$a2=array("a"=>"Computer","b"=>"CPU","c"=>"Mouse");
echo("After array_uintersect_assoc function value is <br/>");
print_r(array_uintersect_assoc($a1,$a2,"mydemo"));
?>
</body>
</html>
|
Output
You may also want to read these related articles here
Ask Your Question
Got a programming related question? You may want to post your question here