@@ -24,6 +24,55 @@ function filter_has_var(int $type, string $variable_name): void
24
24
}
25
25
26
26
27
+ /**
28
+ * This function is useful for retrieving many values without
29
+ * repetitively calling filter_input.
30
+ *
31
+ * @param int $type One of INPUT_GET, INPUT_POST,
32
+ * INPUT_COOKIE, INPUT_SERVER, or
33
+ * INPUT_ENV.
34
+ * @param int|array $definition An array defining the arguments. A valid key is a string
35
+ * containing a variable name and a valid value is either a filter type, or an array
36
+ * optionally specifying the filter, flags and options. If the value is an
37
+ * array, valid keys are filter which specifies the
38
+ * filter type,
39
+ * flags which specifies any flags that apply to the
40
+ * filter, and options which specifies any options that
41
+ * apply to the filter. See the example below for a better understanding.
42
+ *
43
+ * This parameter can be also an integer holding a filter constant. Then all values in the
44
+ * input array are filtered by this filter.
45
+ * @param bool $add_empty Add missing keys as NULL to the return value.
46
+ * @return mixed An array containing the values of the requested variables on success.
47
+ * If the input array designated by type is not populated,
48
+ * the function returns NULL if the FILTER_NULL_ON_FAILURE
49
+ * flag is not given, or FALSE otherwise. For other failures, FALSE is returned.
50
+ *
51
+ * An array value will be FALSE if the filter fails, or NULL if
52
+ * the variable is not set. Or if the flag FILTER_NULL_ON_FAILURE
53
+ * is used, it returns FALSE if the variable is not set and NULL if the filter
54
+ * fails. If the add_empty parameter is FALSE, no array
55
+ * element will be added for unset variables.
56
+ * @throws FilterException
57
+ *
58
+ */
59
+ function filter_input_array (int $ type , $ definition = null , bool $ add_empty = true )
60
+ {
61
+ error_clear_last ();
62
+ if ($ add_empty !== true ) {
63
+ $ result = \filter_input_array ($ type , $ definition , $ add_empty );
64
+ } elseif ($ definition !== null ) {
65
+ $ result = \filter_input_array ($ type , $ definition );
66
+ } else {
67
+ $ result = \filter_input_array ($ type );
68
+ }
69
+ if ($ result === false ) {
70
+ throw FilterException::createFromPhpError ();
71
+ }
72
+ return $ result ;
73
+ }
74
+
75
+
27
76
/**
28
77
* This function is useful for retrieving many values without
29
78
* repetitively calling filter_var.
0 commit comments