reference/array/functions/array-diff-uassoc.xml
6b64170daac5587bee4bb63c0020cb2fbf7f1253
...
...
@@ -10,13 +10,12 @@
10
10
&reftitle.description;
11
11
<methodsynopsis>
12
12
<type>array</type><methodname>array_diff_uassoc</methodname>
13
-
<methodparam><type>array</type><parameter>array1</parameter></methodparam>
14
-
<methodparam><type>array</type><parameter>array2</parameter></methodparam>
15
-
<methodparam choice="opt"><type>array</type><parameter>...</parameter></methodparam>
13
+
<methodparam><type>array</type><parameter>array</parameter></methodparam>
14
+
<methodparam rep="repeat"><type>array</type><parameter>arrays</parameter></methodparam>
16
15
<methodparam><type>callable</type><parameter>key_compare_func</parameter></methodparam>
17
16
</methodsynopsis>
18
17
<para>
19
-
Compares <parameter>array1</parameter> against <parameter>array2</parameter> and
18
+
Compares <parameter>array</parameter> against <parameter>arrays</parameter> and
20
19
returns the difference. Unlike <function>array_diff</function> the array
21
20
keys are used in the comparison.
22
21
</para>
...
...
@@ -32,7 +31,7 @@
32
31
<variablelist>
33
32

34
33
<varlistentry>
35
-
<term><parameter>array1</parameter></term>
34
+
<term><parameter>array</parameter></term>
36
35
<listitem>
37
36
<para>
38
37
The array to compare from
...
...
@@ -41,19 +40,10 @@
41
40
</varlistentry>
42
41

43
42
<varlistentry>
44
-
<term><parameter>array2</parameter></term>
43
+
<term><parameter>arrays</parameter></term>
45
44
<listitem>
46
45
<para>
47
-
An array to compare against
48
-
</para>
49
-
</listitem>
50
-
</varlistentry>
51
-

52
-
<varlistentry>
53
-
<term><parameter>...</parameter></term>
54
-
<listitem>
55
-
<para>
56
-
More arrays to compare against
46
+
Arrays to compare against
57
47
</para>
58
48
</listitem>
59
49
</varlistentry>
...
...
@@ -61,10 +51,7 @@
61
51
<varlistentry>
62
52
<term><parameter>key_compare_func</parameter></term>
63
53
<listitem>
64
-
<para>
65
-
&return.callbacksort;
66
-
</para>
67
-
&callback.cmp;
54
+
&sort.callback.description;
68
55
</listitem>
69
56
</varlistentry>
70
57

...
...
@@ -76,7 +63,7 @@
76
63
&reftitle.returnvalues;
77
64
<para>
78
65
Returns an <type>array</type> containing all the entries from
79
-
<parameter>array1</parameter> that are not present in any of the other arrays.
66
+
<parameter>array</parameter> that are not present in any of the other arrays.
80
67
</para>
81
68
</refsect1>
82
69

...
...
@@ -93,21 +80,20 @@
93
80
<example>
94
81
<title><function>array_diff_uassoc</function> example</title>
95
82
<para>
96
-
The <literal>"a" =&gt; "green"</literal>
83
+
In this example the <literal>"a" =&gt; "green"</literal>
97
84
pair is present in both arrays and thus it is not in the output from the
98
85
function. Unlike this, the pair <literal>0 =&gt; "red"</literal>
99
-
is in the output because in the second argument <literal>"red"</literal>
100
-
has key which is <literal>1</literal>.
86
+
is in the output because the key of <literal>"red"</literal> is
87
+
automatically assigned to <literal>0</literal> in the first array,
88
+
whereas it is assigned to <literal>1</literal> in the second array as the
89
+
key <literal>0</literal> is already taken by <literal>yellow</literal>.
101
90
</para>
102
91
<programlisting role="php">
103
92
<![CDATA[
104
93
<?php
105
94
function key_compare_func($a, $b)
106
95
{
107
-
if ($a === $b) {
108
-
return 0;
109
-
}
110
-
return ($a > $b)? 1:-1;
96
+
return $a <=> $b;
111
97
}
112
98

113
99
$array1 = array("a" => "green", "b" => "brown", "c" => "blue", "red");
...
...
@@ -139,8 +125,8 @@ Array
139
125
&reftitle.notes;
140
126
<note>
141
127
<para>
142
-
This function only checks one dimension of a n-dimensional
143
-
array. Of course you can check deeper dimensions by using, for example,
128
+
This function only checks one dimension of an n-dimensional
129
+
array. It is possible to check deeper dimensions by using, for example,
144
130
<literal>array_diff_uassoc($array1[0], $array2[0], "key_compare_func");</literal>.
145
131
</para>
146
132
</note>
147
133