Menu
Riverview Church

FILTER_VAR_ARRAY

Gets multiple variables and optionally filters them

SYNTAX

filter_var_array ( array $data [, mixed $definition [, bool $add_empty = TRUE ]] ) : mixed

PARAMETERS

data

An array with string keys containing the data to filter.

definition

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.

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

add_empty

Add missing keys as NULL to the return value.

RETURN

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.

EXAMPLES

DATA

Array
(
    [myvariable1] => 0
    [myvariable2] => Array
        (
            [0] => 0
            [1] => 1
        )

)

DEFINITION

Array
(
    [myvariable1] => Array
        (
            [0] => 0
        )

    [myvariable2] => Array
        (
            [0] =>
            [1] => 1
        )

    [myvariable3] =>
)

ADD_EMPTY

Array
(
    [myvariable1] => Array
        (
            [0] => 0
        )

    [myvariable2] => Array
        (
            [0] =>
            [1] => 1
        )

)

1

array (
'product_id' => 'libgd%3Cscript%3E',
'component' =>
array (
    0 => 10,
),
'versions' => '2.0.33',
'doesnotexist' => NULL,
'testscalar' => false,
'testarray' =>
array (
    0 => 2,
),
)

PHP