php man page for array_diff

Query: array_diff

OS: php

Section: 3

Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar

ARRAY_DIFF(3)								 1							     ARRAY_DIFF(3)

array_diff - Computes the difference of arrays

SYNOPSIS
array array_diff (array $array1, array $array2, [array $...])
DESCRIPTION
Compares $array1 against one or more other arrays and returns the values in $array1 that are not present in any of the other arrays.
PARAMETERS
o $array1 - The array to compare from o $array2 - An array to compare against o $... - More arrays to compare against
RETURN VALUES
Returns an array containing all the entries from $array1 that are not present in any of the other arrays.
EXAMPLES
Example #1 array_diff(3) example <?php $array1 = array("a" => "green", "red", "blue", "red"); $array2 = array("b" => "green", "yellow", "red"); $result = array_diff($array1, $array2); print_r($result); ?> Multiple occurrences in $array1 are all treated the same way. This will output : Array ( [1] => blue )
NOTES
Note Two elements are considered equal if and only if (string) $elem1 === (string) $elem2. In words: when the string representation is the same. Note This function only checks one dimension of a n-dimensional array. Of course you can check deeper dimensions by using array_diff($array1[0], $array2[0]);.
SEE ALSO
array_diff_assoc(3), array_intersect(3), array_intersect_assoc(3). PHP Documentation Group ARRAY_DIFF(3)
Related Man Pages
array_uintersect(3) - php
array_diff_uassoc(3) - php
array_intersect_uassoc(3) - php
array_intersect_ukey(3) - php
array_uintersect_assoc(3) - php
Similar Topics in the Unix Linux Community
List Duplicate
Comparing Variables in Perl
Using Bash scripting to compare arrays looking for matches
Recursive function and arrays
Modifying the values of dynamically named arrays