Home  >  Article  >  Backend Development  >  PHP filter_var_array example tutorial_PHP tutorial

PHP filter_var_array example tutorial_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 11:00:271026browse

Definition and usage
The filter_var_array() function gets multiple variables and their selected filter

This feature is useful for filtering many values ​​without requiring filter_var(), much more.

Returns an array of values ​​in the requested variable on success or FALSE on failure.

Grammar

filter_var_array(array, args)

<!--?php$arr = array ( "name" =-->"peter griffin", "age" => "41", "email" => "peter@example.com", );
$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_var_array($arr, $filters));?>
 
输出结果.
 

Array ( [name] => Peter Griffin [age] => 41 [email] => peter@example.com )

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445508.htmlTechArticleDefinition and Usage The filter_var_array() function is useful to obtain multiple variables and their selected filters. Filtering many values ​​does not require filter_var(), much more. Return to...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn