Make a Filter Input with array key

0

I'm getting data from a form, and it has a field that is in array of $_POST which looks like this:

Array
(
    [image_ids] => Array
        (
            [0] => 831
            [1] => 789
        )
)

And I want to get the value by filter_input this way:

$images = filter_input(INPUT_POST, 'image_ids');

And I can not, does anyone have any idea how I get these values?

NOTE: variable images returns False when giving var_dump

    
asked by anonymous 28.09.2018 / 23:32

1 answer

0

I put this code and it worked:

$filters = array(
        'image_ids' => array(
             'filter' => FILTER_VALIDATE_INT,
             'flags' => FILTER_REQUIRE_ARRAY
        )
);
$images = filter_input_array(INPUT_POST, $filters);
    
29.09.2018 / 00:58