Unix and Linux Discussions Tagged with arrays |
|
Thread / Thread Starter |
Last Post |
Replies |
Views |
Forum |
|
|
|
21 |
6,728 |
UNIX for Beginners Questions & Answers |
|
|
|
1 |
2,462 |
UNIX for Beginners Questions & Answers |
|
|
|
6 |
3,818 |
UNIX for Beginners Questions & Answers |
|
|
|
2 |
3,921 |
UNIX for Beginners Questions & Answers |
|
|
|
2 |
2,160 |
Shell Programming and Scripting |
|
|
|
4 |
1,208 |
UNIX for Beginners Questions & Answers |
|
|
|
6 |
3,392 |
Programming |
|
|
|
2 |
2,484 |
Shell Programming and Scripting |
|
|
|
7 |
5,071 |
UNIX for Beginners Questions & Answers |
|
|
|
5 |
2,439 |
Shell Programming and Scripting |
|
|
|
6 |
3,885 |
UNIX for Dummies Questions & Answers |
|
|
|
15 |
9,049 |
Shell Programming and Scripting |
|
|
|
8 |
8,094 |
Programming |
|
|
|
2 |
1,880 |
Shell Programming and Scripting |
|
|
|
10 |
7,844 |
Shell Programming and Scripting |
|
|
|
6 |
2,383 |
UNIX for Dummies Questions & Answers |
|
|
|
1 |
16,873 |
Shell Programming and Scripting |
|
|
|
4 |
4,177 |
Programming |
|
|
|
5 |
1,844 |
Shell Programming and Scripting |
|
|
|
5 |
4,437 |
Homework & Coursework Questions |
|
|
|
3 |
2,552 |
UNIX for Dummies Questions & Answers |
|
|
|
3 |
2,723 |
Shell Programming and Scripting |
|
|
|
1 |
2,616 |
Shell Programming and Scripting |
|
|
|
1 |
2,468 |
Shell Programming and Scripting |
|
|
|
1 |
3,346 |
UNIX for Dummies Questions & Answers |
|
|
|
4 |
4,232 |
Emergency UNIX and Linux Support |
|
|
|
7 |
13,076 |
Shell Programming and Scripting |
|
|
|
12 |
29,862 |
Shell Programming and Scripting |
|
|
|
7 |
19,489 |
Shell Programming and Scripting |
|
|
|
0 |
5,208 |
Shell Programming and Scripting |
|
|
|
0 |
2,731 |
Shell Programming and Scripting |
|
|
|
3 |
4,078 |
Web Development |
|
|
|
1 |
3,943 |
Shell Programming and Scripting |
|
|
|
3 |
3,110 |
Shell Programming and Scripting |
|
|
|
1 |
5,414 |
Shell Programming and Scripting |
|
|
|
3 |
2,422 |
Shell Programming and Scripting |
|
|
|
1 |
3,975 |
Shell Programming and Scripting |
|
|
|
2 |
9,573 |
Shell Programming and Scripting |
|
|
|
4 |
10,251 |
Shell Programming and Scripting |
|
|
|
1 |
1,423 |
Shell Programming and Scripting |
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)