reference/filter/functions/filter-input-array.xml
de9c65c91ff1710d8b2d2ec955caea0162679305
...
...
@@ -8,10 +8,10 @@
8
8
<refsect1 role="description">
9
9
&reftitle.description;
10
10
<methodsynopsis>
11
-
<type>mixed</type><methodname>filter_input_array</methodname>
11
+
<type class="union"><type>array</type><type>false</type><type>null</type></type><methodname>filter_input_array</methodname>
12
12
<methodparam><type>int</type><parameter>type</parameter></methodparam>
13
-
<methodparam choice="opt"><type>mixed</type><parameter>definition</parameter></methodparam>
14
-
<methodparam choice="opt"><type>bool</type><parameter>add_empty</parameter><initializer>true</initializer></methodparam>
13
+
<methodparam choice="opt"><type class="union"><type>array</type><type>int</type></type><parameter>options</parameter><initializer><constant>FILTER_DEFAULT</constant></initializer></methodparam>
14
+
<methodparam choice="opt"><type>bool</type><parameter>add_empty</parameter><initializer>&true;</initializer></methodparam>
15
15
</methodsynopsis>
16
16
<para>
17
17
This function is useful for retrieving many values without
...
...
@@ -33,7 +33,7 @@
33
33
</listitem>
34
34
</varlistentry>
35
35
<varlistentry>
36
-
<term><parameter>definition</parameter></term>
36
+
<term><parameter>options</parameter></term>
37
37
<listitem>
38
38
<para>
39
39
An array defining the arguments. A valid key is a <type>string</type>
...
...
@@ -67,11 +67,17 @@
67
67
<refsect1 role="returnvalues">
68
68
&reftitle.returnvalues;
69
69
<para>
70
-
An array containing the values of the requested variables on success, or &false;
71
-
on failure. An array value will be &false; if the filter fails, or &null; if
70
+
An array containing the values of the requested variables on success.
71
+
If the input array designated by <parameter>type</parameter> is not populated,
72
+
the function returns &null; if the <constant>FILTER_NULL_ON_FAILURE</constant>
73
+
flag is not given, or &false; otherwise. For other failures, &false; is returned.
74
+
</para>
75
+
<para>
76
+
An array value will be &false; if the filter fails, or &null; if
72
77
the variable is not set. Or if the flag <constant>FILTER_NULL_ON_FAILURE</constant>
73
78
is used, it returns &false; if the variable is not set and &null; if the filter
74
-
fails.
79
+
fails. If the <parameter>add_empty</parameter> parameter is &false;, no array
80
+
element will be added for unset variables.
75
81
</para>
76
82
</refsect1>
77
83

...
...
@@ -83,14 +89,14 @@
83
89
<programlisting role="php">
84
90
<![CDATA[
85
91
<?php
86
-
error_reporting(E_ALL | E_STRICT);
92
+

87
93
/* data actually came from POST
88
94
$_POST = array(
89
-
'product_id' => 'libgd<script>',
90
-
'component' => '10',
91
-
'versions' => '2.0.33',
92
-
'testscalar' => array('2', '23', '10', '12'),
93
-
'testarray' => '2',
95
+
'product_id' => 'libgd<script>',
96
+
'component' => array('10'),
97
+
'version' => '2.0.33',
98
+
'testarray' => array('2', '23', '10', '12'),
99
+
'testscalar' => '2',
94
100
);
95
101
*/
96
102

...
...
@@ -100,7 +106,7 @@ $args = array(
100
106
'flags' => FILTER_REQUIRE_ARRAY,
101
107
'options' => array('min_range' => 1, 'max_range' => 10)
102
108
),
103
-
'versions' => FILTER_SANITIZE_ENCODED,
109
+
'version' => FILTER_SANITIZE_ENCODED,
104
110
'doesnotexist' => FILTER_VALIDATE_INT,
105
111
'testscalar' => array(
106
112
'filter' => FILTER_VALIDATE_INT,
...
...
@@ -125,28 +131,28 @@ echo "\n";
125
131
<![CDATA[
126
132
array(6) {
127
133
["product_id"]=>
128
-
array(1) {
129
-
[0]=>
130
-
string(17) "libgd%3Cscript%3E"
131
-
}
134
+
string(17) "libgd%3Cscript%3E"
132
135
["component"]=>
133
136
array(1) {
134
137
[0]=>
135
138
int(10)
136
139
}
137
-
["versions"]=>
138
-
array(1) {
139
-
[0]=>
140
-
string(6) "2.0.33"
141
-
}
140
+
["version"]=>
141
+
string(6) "2.0.33"
142
142
["doesnotexist"]=>
143
143
NULL
144
144
["testscalar"]=>
145
-
bool(false)
145
+
int(2)
146
146
["testarray"]=>
147
-
array(1) {
147
+
array(4) {
148
148
[0]=>
149
149
int(2)
150
+
[1]=>
151
+
int(23)
152
+
[2]=>
153
+
int(10)
154
+
[3]=>
155
+
int(12)
150
156
}
151
157
}
152
158
]]>
...
...
@@ -155,30 +161,6 @@ array(6) {
155
161
</para>
156
162
</refsect1>
157
163

158
-
<refsect1 role="changelog">
159
-
&reftitle.changelog;
160
-
<para>
161
-
<informaltable>
162
-
<tgroup cols="2">
163
-
<thead>
164
-
<row>
165
-
<entry>&Version;</entry>
166
-
<entry>&Description;</entry>
167
-
</row>
168
-
</thead>
169
-
<tbody>
170
-
<row>
171
-
<entry>5.4.0</entry>
172
-
<entry>
173
-
Added <parameter>add_empty</parameter> parameter.
174
-
</entry>
175
-
</row>
176
-
</tbody>
177
-
</tgroup>
178
-
</informaltable>
179
-
</para>
180
-
</refsect1>
181
-

182
164
<refsect1 role="notes">
183
165
&reftitle.notes;
184
166
<note>
...
...
@@ -196,13 +178,12 @@ array(6) {
196
178
<simplelist>
197
179
<member><function>filter_input</function></member>
198
180
<member><function>filter_var_array</function></member>
199
-
<member><xref linkend="filter.filters" /></member>
181
+
<member><xref linkend="filter.filters"/></member>
200
182
</simplelist>
201
183
</para>
202
184
</refsect1>
203
185

204
186
</refentry>
205
-

206
187
<!-- Keep this comment at the end of the file
207
188
Local variables:
208
189
mode: sgml
209
190