PHP array_diff_uassoc() Function

The array_diff_uassoc() function is used to compare two or more arrays with an additional user supplied function. The function compares array1 against array2 and returns the difference. Unlike array_diff() the array keys are used in the comparison.

Note: This function uses a user-defined function to compare the keys!

Parameter Description
array1 Required. The array to compare from
array2 Required. An array to compare against
array3,… Optional. More arrays to compare against
myfunction Required. A string that define a callable comparison function. The comparison function must return an integer <, =, or > than 0 if the first argument is <, =, or > than the second argument




function myfunction($a,$b)
	if ($a==$b)
	  return 0;
	return ($a>$b)?1:-1;


Array ( [d] => Cooper ) 

Leave a Reply

Your email address will not be published. Required fields are marked *