reference/array/functions/array-unique.xml
651fad6c6677036edd2871bb78199e17586a3acd
...
...
@@ -11,7 +11,7 @@
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
...
...
@@ -19,13 +19,13 @@
19
19
</para>
20
20
<para>
21
21
Note that keys are preserved. If multiple elements compare equal under
22
-
the given <parameter>sort_flags</parameter>, then the key and value of
22
+
the given <parameter>flags</parameter>, then the key and value of
23
23
the first equal element will be retained.
24
24
</para>
25
25
<note>
26
26
<simpara>
27
27
Two elements are considered equal if and only if
28
-
<literal>(string) $elem1 === (string) $elem2</literal> i.e.
28
+
<literal>(string) $elem1 === (string) $elem2</literal>, i.e.
29
29
when the string representation is the same, the first element will be used.
30
30
</simpara>
31
31
</note>
...
...
@@ -44,14 +44,14 @@
44
44
</listitem>
45
45
</varlistentry>
46
46
<varlistentry>
47
-
<term><parameter>sort_flags</parameter></term>
47
+
<term><parameter>flags</parameter></term>
48
48
<listitem>
49
49
<para>
50
-
The optional second parameter <parameter>sort_flags</parameter>
51
-
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:
52
52
</para>
53
53
<para>
54
-
Sorting type flags:
54
+
Comparison type flags:
55
55
<itemizedlist>
56
56
<listitem>
57
57
<simpara><constant>SORT_REGULAR</constant> - compare items normally
...
...
@@ -98,28 +98,13 @@
98
98
<row>
99
99
<entry>7.2.0</entry>
100
100
<entry>
101
-
If <parameter>sort_flags</parameter> is <constant>SORT_STRING</constant>,
101
+
If <parameter>flags</parameter> is <constant>SORT_STRING</constant>,
102
102
formerly <parameter>array</parameter> has been copied and non-unique
103
103
elements have been removed (without packing the array afterwards), but
104
104
now a new array is built by adding the unique elements. This can result
105
105
in different numeric indexes.
106
106
</entry>
107
107
</row>
108
-
<row>
109
-
<entry>5.2.10</entry>
110
-
<entry>
111
-
Changed the default value of <parameter>sort_flags</parameter> back to
112
-
<constant>SORT_STRING</constant>.
113
-
</entry>
114
-
</row>
115
-
<row>
116
-
<entry>5.2.9</entry>
117
-
<entry>
118
-
Added the optional <parameter>sort_flags</parameter> defaulting
119
-
to <constant>SORT_REGULAR</constant>. Prior to 5.2.9, this function used to sort
120
-
the array with <constant>SORT_STRING</constant> internally.
121
-
</entry>
122
-
</row>
123
108
</tbody>
124
109
</tgroup>
125
110
</informaltable>
...
...
@@ -134,9 +119,11 @@
134
119
<programlisting role="php">
135
120
<![CDATA[
136
121
<?php
137
-
$input = array("a" => "green", "red", "b" => "green", "blue", "red");
122
+

123
+
$input = ["a" => "green", "red", "b" => "green", "blue", "red"];
138
124
$result = array_unique($input);
139
125
print_r($result);
126
+

140
127
?>
141
128
]]>
142
129
</programlisting>
...
...
@@ -159,9 +146,11 @@ Array
159
146
<programlisting role="php">
160
147
<![CDATA[
161
148
<?php
162
-
$input = array(4, "4", "3", 4, 3, "3");
149
+

150
+
$input = [4, "4", "3", 4, 3, "3"];
163
151
$result = array_unique($input);
164
152
var_dump($result);
153
+

165
154
?>
166
155
]]>
167
156
</programlisting>
...
...
@@ -178,15 +167,6 @@ array(2) {
178
167
</para>
179
168
</refsect1>
180
169

181
-
<refsect1 role="seealso">
182
-
&reftitle.seealso;
183
-
<para>
184
-
<simplelist>
185
-
<member><function>array_count_values</function></member>
186
-
</simplelist>
187
-
</para>
188
-
</refsect1>
189
-

190
170
<refsect1 role="notes">
191
171
&reftitle.notes;
192
172
<note>
...
...
@@ -197,8 +177,16 @@ array(2) {
197
177
</note>
198
178
</refsect1>
199
179

200
-
</refentry>
180
+
<refsect1 role="seealso">
181
+
&reftitle.seealso;
182
+
<para>
183
+
<simplelist>
184
+
<member><function>array_count_values</function></member>
185
+
</simplelist>
186
+
</para>
187
+
</refsect1>
201
188

189
+
</refentry>
202
190
<!-- Keep this comment at the end of the file
203
191
Local variables:
204
192
mode: sgml
205
193