PHP Filter_var_array Function

What is filter_var_array() in PHP?


filter_var_array() is a function which validates and filters multiple values stored in the variables.


filter_var_array(array, args)

In the above syntax, 'array' is the variables to be filtered and validated. 'args' is the filters used to validate.

This function validates for multiple values without calling filter_var() many times.

Example :

$arr = array
"name" => "",
"age" => "10",
"email" => "",
$filters = array
"name" => array
"age" => array
print_r(filter_var_array($arr, $filters));

Result :

Array ( [name] => [age] => 10 [email] => )

In the above example, the values stored in the array $arr is filtered and validated using the $filters, which is an array of filters.

PHP Topics

Ask Questions

Ask Question