reference/array/functions/array-filter.xml
31cacb6f262f455c616094cfe6d09bc0d1df2748
...
...
@@ -11,15 +11,19 @@
11
11
<methodsynopsis>
12
12
<type>array</type><methodname>array_filter</methodname>
13
13
<methodparam><type>array</type><parameter>array</parameter></methodparam>
14
-
<methodparam choice="opt"><type>callable</type><parameter>callback</parameter></methodparam>
15
-
<methodparam choice="opt"><type>int</type><parameter>flag</parameter><initializer>0</initializer></methodparam>
14
+
<methodparam choice="opt"><type class="union"><type>callable</type><type>null</type></type><parameter>callback</parameter><initializer>&null;</initializer></methodparam>
15
+
<methodparam choice="opt"><type>int</type><parameter>mode</parameter><initializer>0</initializer></methodparam>
16
16
</methodsynopsis>
17
17
<para>
18
18
Iterates over each value in the <parameter>array</parameter>
19
19
passing them to the <parameter>callback</parameter> function.
20
20
If the <parameter>callback</parameter> function returns &true;, the
21
21
current value from <parameter>array</parameter> is returned into
22
-
the result &array;. Array keys are preserved.
22
+
the result &array;.
23
+
</para>
24
+
<para>
25
+
Array keys are preserved, and may result in gaps if the <parameter>array</parameter> was indexed.
26
+
The result &array; can be reindexed using the <function>array_values</function> function.
23
27
</para>
24
28
</refsect1>
25
29

...
...
@@ -44,16 +48,15 @@
44
48
The callback function to use
45
49
</para>
46
50
<para>
47
-
If no <parameter>callback</parameter> is supplied, all entries of
48
-
<parameter>array</parameter> equal to &false; (see
49
-
<link linkend="language.types.boolean.casting">converting to
50
-
boolean</link>) will be removed.
51
+
If no <parameter>callback</parameter> is supplied, all empty entries of
52
+
<parameter>array</parameter> will be removed. See <function>empty</function>
53
+
for how PHP defines empty in this case.
51
54
</para>
52
55
</listitem>
53
56
</varlistentry>
54
57

55
58
<varlistentry>
56
-
<term><parameter>flag</parameter></term>
59
+
<term><parameter>mode</parameter></term>
57
60
<listitem>
58
61
<para>
59
62
Flag determining what arguments are sent to <parameter>callback</parameter>:
...
...
@@ -96,13 +99,12 @@
96
99
</thead>
97
100
<tbody>
98
101
<row>
99
-
<entry>5.6.0</entry>
102
+
<entry>8.0.0</entry>
100
103
<entry>
101
-
Added optional <parameter>flag</parameter> parameter and constants
102
-
<constant>ARRAY_FILTER_USE_KEY</constant> and
103
-
<constant>ARRAY_FILTER_USE_BOTH</constant>
104
+
<parameter>callback</parameter> is nullable now.
104
105
</entry>
105
106
</row>
107
+
&array.changelog.by-ref;
106
108
</tbody>
107
109
</tgroup>
108
110
</informaltable>
...
...
@@ -200,7 +202,7 @@ Array
200
202
</example>
201
203
<example>
202
204
<title><function>array_filter</function> with
203
-
<parameter>flag</parameter></title>
205
+
<parameter>mode</parameter></title>
204
206
<programlisting role="php">
205
207
<![CDATA[
206
208
<?php
...
...
@@ -250,6 +252,7 @@ array(2) {
250
252
&reftitle.seealso;
251
253
<para>
252
254
<simplelist>
255
+
<member><function>array_intersect</function></member>
253
256
<member><function>array_map</function></member>
254
257
<member><function>array_reduce</function></member>
255
258
<member><function>array_walk</function></member>
...
...
@@ -258,7 +261,6 @@ array(2) {
258
261
</refsect1>
259
262

260
263
</refentry>
261
-

262
264
<!-- Keep this comment at the end of the file
263
265
Local variables:
264
266
mode: sgml
265
267