PHP filter_input_array() Function

PHP filter_input_array Function


Define :

In this tutorial we have learned about PHP filter_input_array() Function.The filter_input_array() function is inbuilt function in php.This function is used to   gets external variables and optionally filters them. This function is useful for retrieving many values without repetitively calling filter_input().

Syntax
 filter_input_array(type, options, add_empty)
Parameters
type Required. Specify the input type. It can be one of the following:
  • INPUT_GET
  • INPUT_POST
  • INPUT_COOKIE
  • INPUT_SERVER
  • INPUT_ENV

 

Example :

In the example below, filter_input_array() function is used to filter three POST variables. The received POST variables are 'name', 'age' and 'email'. 

Output : 

Array
(
    [name] => John Smith
    [age] => 25
    [email] => John@example.com
)