Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
filter_var_array() function in PHP
The filter_var_array() function is used to filter multiple variables.
Syntax
filter_var_array(arrayname, parameters)
Parameters
arrayname − An array to filter the data.
parameters − It specifies an array of filter arguments.
Return
The filter_var_array() function returns an array of values of the requested variables on success or false on failure.
Example
<?php
$arr = Array (
"stname" => "Jack",
"stmarks" => "95",
"stemail" => "jack@abcde.com",
);
$filters = array (
"stname" => array (
"filter"=>FILTER_CALLBACK,
"flags"=>FILTER_FORCE_ARRAY,
"options"=>"ucwords"
),
"stmarks" => array (
"filter"=>FILTER_VALIDATE_INT,
"options"=>array (
"min_range"=>1,
"max_range"=>100
)
),
"stemail"=> FILTER_VALIDATE_EMAIL,
);
print_r(filter_var_array($arr, $filters));
?>
The following is the output.
Array ( [stname] => Jack [stmarks] => 95 [stemail] => jack@abcde.com )
Advertisements