PHP array_udiff_uassoc() Function

6 Jan 2025 | 2 min read

The array_udiff_uassoc( ) function is an inbuilt function of PHP. The array_udiff_uassoc( ) function compares two or more arrays in two user-made functions, and returns an array containing the elements from the first array. This function was introduced in PHP 5.0.

Syntax

Parameters

ParameterDescriptionRequired/Optional
array1Array to compare from.compulsory
array2Array to compare against.compulsory
array3More arrays to compare against.Optional
Value_compare_functionUser-defined function to compare the array values.compulsory
Key_compare_functionUser-defined function to compare the array keys.compulsory

Return Values

The array_udiff_uassoc( ) function returns an array containing all the values from array1 that are not present in any of the other arguments.

Example 1

Output:

 Array ( [c] => vivo ) 

Example 2

Output:

 Array ( [c] =>virat ) 

Example 3

Output:

 Array ( [c] =>ndtv ) 

Example 4

Output:

 Array ( [m] => C [n] => Java [o] => C# [y] => python )