Heim >Backend-Entwicklung >PHP-Tutorial >PHP filter_var_array 实例教程_PHP教程
定义和用法
该filter_var_array ( )函数获得多个变量和它们选择的过滤器
这一功能是有益的过滤许多价值不要求filter_var ( ) ,多。
返回一个数组的价值观所要求的变量成功或FALSE的失败。
语法
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 )