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

PHP filter_var_array example tutorial_PHP tutorial

WBOY
Release: 2016-07-20 11:00:27
Original
1082 people have browsed it

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)
Copy after login
Copy after login
Copy after login
<!--?php$arr = array ( "name" =-->"peter griffin", "age" => "41", "email" => "peter@example.com", );
Copy after login
$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, );
Copy after login
print_r(filter_var_array($arr, $filters));?>
Copy after login
 
Copy after login
Copy after login
输出结果.
Copy after login
 
Copy after login
Copy after login
Copy after login
Copy after login
Array ( [name] => Peter Griffin [age] => 41 [email] => peter@example.com )
Copy after login

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...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template