定義和用法
該filter_var_array ( )函數獲得多個變量和它們選擇的過濾器
這一功能是有益的過濾許多價值不要求filter_var ( ) ,多。
返回一個數組的價值觀所要求的變量成功或FALSE的失敗。
語法
filter_var_array(array, args)
"peter griffin", "age" => "41", "email" => "[email protected]", );
$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] => [email protected] )