How to use array diff uassoc in PHP
In this article, I will explain how the array() function can be used in PHP.
array_diff_uassoc() function in PHP
-
The array_diff_uassoc() function compares two or more arrays checking for differences with additional user supplied function.
-
In array_diff_uassoc() function, both the key and the value is used in the comparison and in the user-defined function, only the keys are being compared.
Syntax
array_diff_uassoc(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 made by user.
Example
The following example show to how the array_diff_uassoc() function can be used in PHP.
<h3 style="color: brown;">array_diff_uassoc() function example in PHP</h3>
<?php function mydemo($a1,$a2)
{
if ($a1===$a2)
{
return 0;
}
if ($a1>$a2)
{
return 1;
}
else
{
return -1;
}
}
$i1=array(0=>"Nitin",1=>"Manish",2=>"Aman");
$i2=array(2=>"Rajesh",3=>"Saurabh",4=>"Ravi");
$i3=array(5=>"Arvind",6=>"Sunny",7=>"Neeraj");
print_r(array_diff_uassoc($i1,$i2,$i3,"mydemo"));
?> |
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