IMPRESS dotted_line CONTACT dotted_line search dotted_line Kontakt dotted_line sitemap dotted_line print
126 PHP-Resource users online

Switch to another languags Deutsch aktuelle Sprache Englisch

PHP Manual


(PHP 5 >= 5.2.0)

filter_var_arrayGets multiple variables and optionally filters them


mixed filter_var_array ( array $data [, mixed $definition ] )

This function is useful for retrieving many values without repetitively calling filter_var().



An array with string keys containing the data to filter.


An array defining the arguments. A valid key is a string containing a variable name and a valid value is either a filter type, or an array optionally specifying the filter, flags and options. If the value is an array, valid keys are filter which specifies the filter type, flags which specifies any flags that apply to the filter, and options which specifies any options that apply to the filter. See the example below for a better understanding.

This parameter can be also an integer holding a filter constant. Then all values in the input array are filtered by this filter.

Return Values

An array containing the values of the requested variables on success, or FALSE on failure. An array value will be FALSE if the filter fails, or NULL if the variable is not set.


Example #1 A filter_var_array() example

$data = array(
'product_id'    => 'libgd<script>',
'component'     => '10',
'versions'      => '2.0.33',
'testscalar'    => array('2''23''10''12'),
'testarray'     => '2',

$args = array(
'product_id'   => FILTER_SANITIZE_ENCODED,
'component'    => array('filter'    => FILTER_VALIDATE_INT,
'flags'     => FILTER_FORCE_ARRAY
'options'   => array('min_range' => 1'max_range' => 10)
'versions'     => FILTER_SANITIZE_ENCODED,
'doesnotexist' => FILTER_VALIDATE_INT,
'testscalar'   => array(
'testarray'    => array(


$myinputs filter_var_array($data$args);


The above example will output:

array(6) {
  array(1) {
    string(17) "libgd%3Cscript%3E"
  array(1) {
  array(1) {
    string(6) "2.0.33"
  array(1) {

See Also

Comments to the PHP manual
Write new comment


New Tutorial entries

Migration einer PHP 5 App auf PHP 7

Dieses PHP 7 Tutorial zeigt dir, wie du dein PHP5 Script auf PHP7 umstellst.

Berni | Category: PHP
PHP 7 Virtual Machine

Dieser Artikel zielt darauf ab, einen Überblick über die Zend Virtual Machine, wie es in PHP 7 gefunden wird.

Berni | Category: PHP
plotting masters - a professional guide - Teil II

Grafische Interpolation und Bestapproximation von numerischen Wertepaaren: Wir wollen Punkte auf einer Zeichenebene über verschiedene Verfahren miteinander verbinden.

EVAMasters | Category: PHP