reference/filter/functions/filter-input-array.xml
de9c65c91ff1710d8b2d2ec955caea0162679305
...
...
@@ -1,4 +1,4 @@
1
-
<?xml version="1.0" encoding="iso-8859-1"?>
1
+
<?xml version="1.0" encoding="utf-8"?>
2
2
<!-- $Revision$ -->
3
3
<refentry xml:id="function.filter-input-array" xmlns="http://docbook.org/ns/docbook">
4
4
<refnamediv>
...
...
@@ -8,9 +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>
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>
14
15
</methodsynopsis>
15
16
<para>
16
17
This function is useful for retrieving many values without
...
...
@@ -26,25 +27,24 @@
26
27
<listitem>
27
28
<para>
28
29
One of <constant>INPUT_GET</constant>, <constant>INPUT_POST</constant>,
29
-
<constant>INPUT_COOKIE</constant>, <constant>INPUT_SERVER</constant>,
30
-
<constant>INPUT_ENV</constant>, <constant>INPUT_SESSION</constant>, or
31
-
<constant>INPUT_REQUEST</constant>.
30
+
<constant>INPUT_COOKIE</constant>, <constant>INPUT_SERVER</constant>, or
31
+
<constant>INPUT_ENV</constant>.
32
32
</para>
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>
40
-
containing a variable name and a valid value is either a filter type,
41
-
or an <type>array</type> optionally specifying the filter, flags and
42
-
options. If the value is an array, valid keys are
43
-
<literal>filter</literal> which specifies the filter type,
40
+
containing a variable name and a valid value is either a <link
41
+
linkend="filter.filters">filter type</link>, or an <type>array</type>
42
+
optionally specifying the filter, flags and options. If the value is an
43
+
array, valid keys are <literal>filter</literal> which specifies the
44
+
<link linkend="filter.filters">filter type</link>,
44
45
<literal>flags</literal> which specifies any flags that apply to the
45
-
filter, and <literal>options</literal> which specifies any options
46
-
that apply to the filter. See the example below for a better
47
-
understanding.
46
+
filter, and <literal>options</literal> which specifies any options that
47
+
apply to the filter. See the example below for a better understanding.
48
48
</para>
49
49
<para>
50
50
This parameter can be also an integer holding a <link
...
...
@@ -53,17 +53,31 @@
53
53
</para>
54
54
</listitem>
55
55
</varlistentry>
56
+
<varlistentry>
57
+
<term><parameter>add_empty</parameter></term>
58
+
<listitem>
59
+
<para>
60
+
Add missing keys as &null; to the return value.
61
+
</para>
62
+
</listitem>
63
+
</varlistentry>
56
64
</variablelist>
57
65
</para>
58
66
</refsect1>
59
67
<refsect1 role="returnvalues">
60
68
&reftitle.returnvalues;
61
69
<para>
62
-
An array containing the values of the requested variables on success, or &false;
63
-
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
64
77
the variable is not set. Or if the flag <constant>FILTER_NULL_ON_FAILURE</constant>
65
78
is used, it returns &false; if the variable is not set and &null; if the filter
66
-
fails.
79
+
fails. If the <parameter>add_empty</parameter> parameter is &false;, no array
80
+
element will be added for unset variables.
67
81
</para>
68
82
</refsect1>
69
83

...
...
@@ -75,14 +89,14 @@
75
89
<programlisting role="php">
76
90
<![CDATA[
77
91
<?php
78
-
error_reporting(E_ALL | E_STRICT);
92
+

79
93
/* data actually came from POST
80
94
$_POST = array(
81
-
'product_id' => 'libgd<script>',
82
-
'component' => '10',
83
-
'versions' => '2.0.33',
84
-
'testscalar' => array('2', '23', '10', '12'),
85
-
'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',
86
100
);
87
101
*/
88
102

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

164
+
<refsect1 role="notes">
165
+
&reftitle.notes;
166
+
<note>
167
+
<para>
168
+
There is no <literal>REQUEST_TIME</literal> key in
169
+
<constant>INPUT_SERVER</constant> array because it is inserted into the
170
+
<varname>$_SERVER</varname> later.
171
+
</para>
172
+
</note>
173
+
</refsect1>
174
+

150
175
<refsect1 role="seealso">
151
176
&reftitle.seealso;
152
177
<para>
153
178
<simplelist>
154
179
<member><function>filter_input</function></member>
155
180
<member><function>filter_var_array</function></member>
181
+
<member><xref linkend="filter.filters"/></member>
156
182
</simplelist>
157
183
</para>
158
184
</refsect1>
159
185

160
186
</refentry>
161
-

162
187
<!-- Keep this comment at the end of the file
163
188
Local variables:
164
189
mode: sgml
165
190