# array_udiff_uassoc

(PHP 5)

array_udiff_uassocComputes the difference of arrays with additional index check, compares data and indexes by a callback function

### Description

array array_udiff_uassoc ( array `\$array1` , array `\$array2` [, array `\$ ...` ], callable `\$data_compare_func` , callable `\$key_compare_func` )

Computes the difference of arrays with additional index check, compares data and indexes by a callback function.

Note that the keys are used in the comparison unlike array_diff() and array_udiff().

Hide info

### Parameters

`array1`

The first array.

`array2`

The second array.

`data_compare_func`

The comparison function must return an integer less than, equal to, or greater than zero if the first argument is considered to be respectively less than, equal to, or greater than the second.

int callback ( mixed `\$a`, mixed `\$b` )
`key_compare_func`

The comparison of keys (indices) is done also by the callback function `key_compare_func`. This behaviour is unlike what array_udiff_assoc() does, since the latter compares the indices by using an internal function.

### Return Values

Returns an array containing all the values from `array1` that are not present in any of the other arguments.

### Examples

Example #1 array_udiff_uassoc() example

``` <?phpclass cr {    private \$priv_member;    function cr(\$val)    {        \$this->priv_member = \$val;    }    static function comp_func_cr(\$a, \$b)    {        if (\$a->priv_member === \$b->priv_member) return 0;        return (\$a->priv_member > \$b->priv_member)? 1:-1;    }    static function comp_func_key(\$a, \$b)    {        if (\$a === \$b) return 0;        return (\$a > \$b)? 1:-1;    }}\$a = array("0.1" => new cr(9), "0.5" => new cr(12), 0 => new cr(23), 1=> new cr(4), 2 => new cr(-15),);\$b = array("0.2" => new cr(9), "0.5" => new cr(22), 0 => new cr(3), 1=> new cr(4), 2 => new cr(-15),);\$result = array_udiff_uassoc(\$a, \$b, array("cr", "comp_func_cr"), array("cr", "comp_func_key"));print_r(\$result);?> ```

The above example will output:

```Array
(
[0.1] => cr Object
(
[priv_member:private] => 9
)

[0.5] => cr Object
(
[priv_member:private] => 12
)

 => cr Object
(
[priv_member:private] => 23
)
)
```

In our example above you see the "1" => new cr(4) pair is present in both arrays and thus it is not in the output from the function. Keep in mind that you have to supply 2 callback functions.

### Notes

Note: Please note that this function only checks one dimension of a n-dimensional array. Of course you can check deeper dimensions by using, for example, array_udiff_uassoc(\$array1, \$array2, "data_compare_func", "key_compare_func");.

• array_diff() - Computes the difference of arrays
• array_diff_assoc() - Computes the difference of arrays with additional index check
• array_udiff() - Computes the difference of arrays by using a callback function for data comparison
• array_udiff_assoc() - Computes the difference of arrays with additional index check, compares data by a callback function
• array_intersect() - Computes the intersection of arrays
• array_intersect_assoc() - Computes the intersection of arrays with additional index check
• array_uintersect() - Computes the intersection of arrays, compares data by a callback function
• array_uintersect_assoc() - Computes the intersection of arrays with additional index check, compares data by a callback function
• array_uintersect_uassoc() - Computes the intersection of arrays with additional index check, compares data and indexes by a callback functions

Php Version:
{"ft_lang_label":"__label__en","ft_lang_prob":0.6307126,"math_prob":0.9485278,"size":3372,"snap":"2020-24-2020-29","text_gpt3_token_len":859,"char_repetition_ratio":0.16152018,"word_repetition_ratio":0.21052632,"special_character_ratio":0.289739,"punctuation_ratio":0.14387211,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9892908,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-07-08T05:16:47Z\",\"WARC-Record-ID\":\"<urn:uuid:fbc06337-cb02-40b8-8e62-464c711a2b6a>\",\"Content-Length\":\"35194\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:4c02a79c-c50a-4346-b58e-a538db8738f2>\",\"WARC-Concurrent-To\":\"<urn:uuid:07e5d7bd-ad06-4cf0-a260-ef5854dd7f99>\",\"WARC-IP-Address\":\"104.207.148.27\",\"WARC-Target-URI\":\"https://array_udiff_uassoc.onlinephpfunctions.com/\",\"WARC-Payload-Digest\":\"sha1:H22OKSBMBBASIDMCJDR333ZNDAA4OTOE\",\"WARC-Block-Digest\":\"sha1:3Q2D7SGFOQYB27QQDWWJS6ZNTJ3CL4FA\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-29/CC-MAIN-2020-29_segments_1593655896374.33_warc_CC-MAIN-20200708031342-20200708061342-00027.warc.gz\"}"}