Func Array Udiff
# Tutorial Content
# PHP array_udiff() Function
## Definition and Usage
The array_udiff() function compares the values of two or more arrays, and returns the difference.
**Note:** This function uses a user-defined function to compare the values!
**Tip:** You can compare the values of a single array or compare the values of two or more arrays at the same time.
This function compares the values of two or more arrays, and returns an array that contains the elements from array1 that are not present in array2 or array3, etc.
## Syntax
```
array_udiff(array1,array2,array3...,myfunction)
```
## Parameter Values
| Parameter | Description |
|-----------|-------------|
| array1 | Required. The array to compare from |
| array2 | Required. An array to compare against |
| ... | Optional. More arrays to compare against |
| myfunction | Required. A string that defines a callable comparison function. The comparison function must return an integer 0 if the first argument is less than, equal to, or greater than the second argument |
## Technical Details
| Return Value: | Returns an array containing all the values from array1 that are not present in any of the other arrays |
|---------------|--------------------------------------------------------|
| PHP Version: | PHP 5.1.0+ |
## More Examples
### Example 1
Compare three arrays and return the differences:
```php
$b)?1:-1;
}
$a1=array("a"=>"red","b"=>"green","c"=>"blue");
$a2=array("a"=>"red","b"=>"green","c"=>"green");
$result=array_udiff($a1,$a2,"myfunction");
print_r($result);
?>
```
**Result:**
```
Array ( => blue )
```
### Example 2
Compare three arrays using a built-in function to compare values:
```php
"str","b"=>"str","c"=>"str");
$a2=array("a"=>"str","b"=>"str","d"=>"str");
$result=array_udiff($a1,$a2,"strcasecmp");
print_r($result);
?>
```
**Result:**
```
Array ( => str )
```
## Related Functions
* [array_diff()](func-array-diff.html) - Compares arrays, and returns the differences
* [array_diff_assoc()](func-array-diff-assoc.html) - Compares arrays, and returns the differences (also compares index)
* [array_diff_key()](func-array-diff-key.html) - Compares arrays, and returns the differences (only compares the keys)
* [array_diff_uassoc()](func-array-diff-uassoc.html) - Compares arrays, and returns the differences (compares keys and values using a user-defined function)
* [array_udiff_assoc()](func-array-udiff-assoc.html) - Compares arrays, and returns the differences (compares keys and values using a built-in function to compare the keys, and a user-defined function to compare the values)
* [array_udiff_uassoc()](func-array-udiff-uassoc.html) - Compares arrays, and returns the differences (compares keys and values using two user-defined functions)
YouTip