reference/array/functions/array-unique.xml
3ba15fd3dfb8196a1762b1a21a14311e0279284b
...
...
@@ -11,18 +11,16 @@
11
11
<methodsynopsis>
12
12
<type>array</type><methodname>array_unique</methodname>
13
13
<methodparam><type>array</type><parameter>array</parameter></methodparam>
14
-
<methodparam choice="opt"><type>int</type><parameter>sort_flags</parameter><initializer>SORT_STRING</initializer></methodparam>
14
+
<methodparam choice="opt"><type>int</type><parameter>flags</parameter><initializer><constant>SORT_STRING</constant></initializer></methodparam>
15
15
</methodsynopsis>
16
16
<para>
17
17
Takes an input <parameter>array</parameter> and returns a new array
18
18
without duplicate values.
19
19
</para>
20
20
<para>
21
-
Note that keys are preserved. <function>array_unique</function> sorts
22
-
the values treated as string at first, then will keep the first key
23
-
encountered for every value, and ignore all following keys. It does not
24
-
mean that the key of the first related value from the unsorted
25
-
<parameter>array</parameter> will be kept.
21
+
Note that keys are preserved. If multiple elements compare equal under
22
+
the given <parameter>flags</parameter>, then the key and value of
23
+
the first equal element will be retained.
26
24
</para>
27
25
<note>
28
26
<simpara>
...
...
@@ -46,14 +44,14 @@
46
44
</listitem>
47
45
</varlistentry>
48
46
<varlistentry>
49
-
<term><parameter>sort_flags</parameter></term>
47
+
<term><parameter>flags</parameter></term>
50
48
<listitem>
51
49
<para>
52
-
The optional second parameter <parameter>sort_flags</parameter>
53
-
may be used to modify the sorting behavior using these values:
50
+
The optional second parameter <parameter>flags</parameter>
51
+
may be used to modify the comparison behavior using these values:
54
52
</para>
55
53
<para>
56
-
Sorting type flags:
54
+
Comparison type flags:
57
55
<itemizedlist>
58
56
<listitem>
59
57
<simpara><constant>SORT_REGULAR</constant> - compare items normally
...
...
@@ -98,18 +96,13 @@
98
96
</thead>
99
97
<tbody>
100
98
<row>
101
-
<entry>5.2.10</entry>
99
+
<entry>7.2.0</entry>
102
100
<entry>
103
-
Changed the default value of <parameter>sort_flags</parameter> back to
104
-
<constant>SORT_STRING</constant>.
105
-
</entry>
106
-
</row>
107
-
<row>
108
-
<entry>5.2.9</entry>
109
-
<entry>
110
-
Added the optional <parameter>sort_flags</parameter> defaulting
111
-
to <constant>SORT_REGULAR</constant>. Prior to 5.2.9, this function used to sort
112
-
the array with <constant>SORT_STRING</constant> internally.
101
+
If <parameter>flags</parameter> is <constant>SORT_STRING</constant>,
102
+
formerly <parameter>array</parameter> has been copied and non-unique
103
+
elements have been removed (without packing the array afterwards), but
104
+
now a new array is built by adding the unique elements. This can result
105
+
in different numeric indexes.
113
106
</entry>
114
107
</row>
115
108
</tbody>
...
...
@@ -170,15 +163,6 @@ array(2) {
170
163
</para>
171
164
</refsect1>
172
165

173
-
<refsect1 role="seealso">
174
-
&reftitle.seealso;
175
-
<para>
176
-
<simplelist>
177
-
<member><function>array_count_values</function></member>
178
-
</simplelist>
179
-
</para>
180
-
</refsect1>
181
-

182
166
<refsect1 role="notes">
183
167
&reftitle.notes;
184
168
<note>
...
...
@@ -189,8 +173,16 @@ array(2) {
189
173
</note>
190
174
</refsect1>
191
175

192
-
</refentry>
176
+
<refsect1 role="seealso">
177
+
&reftitle.seealso;
178
+
<para>
179
+
<simplelist>
180
+
<member><function>array_count_values</function></member>
181
+
</simplelist>
182
+
</para>
183
+
</refsect1>
193
184

185
+
</refentry>
194
186
<!-- Keep this comment at the end of the file
195
187
Local variables:
196
188
mode: sgml
197
189