Definition and usage
The filter_input_array() function gets multiple filters from external input scripts and filters them.
This feature is useful for filtering large input variables without requiring filter_input(), and more.
This feature can input several sources:
INPUT_GET
INPUT_POST
INPUT_COOKIE
INPUT_ENV
INPUT_SERVER
INPUT_SESSION (not implemented yet)
INPUT_REQUEST (not implemented yet)
Returns an array of filtered data on success, false on failure.
Grammar
filter_input(input_type, args)
input_type:required. Specify the input type. See list of possible types above args: Optional. Arguments that specify a series of filters.
A valid key is a variable name and a valid value is a filter ID or an array specifying filters, flags and selections. This parameter can also be a single filter number, if so, all values in the input array are filtered by the specified filter. The filter number can be a number name (such as FILTER_VALIDATE_EMAIL) or an ID number (such as 274)
Tips and Instructions Tip: Please check PHP filters for full possible reference filters to use this feature.
For example, in this example we use the filter_input_array () function to filter the last three variables.
The variables received are a name, age and e-mail address:
<!--?php$filters = array ( "name" =-->array ( "filter"=>FILTER_CALLBACK, "flags"=>FILTER_FORCE_ARRAY, "options"=>"ucwords" ), "age" => array ( "filter"=>FILTER_VALIDATE_INT, "options"=>array ( "min_range"=>1, "max_range"=>120 ) ), "email"=> FILTER_VALIDATE_EMAIL, );print_r(filter_input_array(INPUT_POST, $filters));?>
返回值勤.
Array ( [name] => Peter [age] => 41 [email] => peter@example.com )