Easy Tutorial
❮ Func Error Set Exception Handler Php Ref Curl ❯

PHP array_diff_assoc() Function

Complete PHP Array Reference Manual

Example

Compare the keys and values of two arrays and return the difference:


Definition and Usage

The array_diff_assoc() function is used to compare the keys and values of two (or more) arrays and return the difference.

This function compares the keys and values of two (or more) arrays and returns an array of differences, which includes all keys and values that are present in the first array (array1) but not in any of the other arrays (array2, array3, etc.).


Syntax

Parameter Description
array1 Required. The first array to compare with other arrays.
array2 Required. An array to compare against the first array.
array3,... Optional. Additional arrays to compare against the first array.

Technical Details

Return Value: Returns an array containing all the keys and values from array1 that are not present in any of the other arrays (array2, array3, etc.).
PHP Version: 4.3+
--- ---

More Examples

Example 1

Compare the keys and values of two arrays and return the difference:

Example 2

Compare the keys and values of three arrays and return the difference:


❮ Func Error Set Exception Handler Php Ref Curl ❯