2

Well I have this page

domain.com/bla.php?p[]=1&p[]=2&p[]=3&p[]=4

Now, $_GET['p'] works as expected. It's an array

However, filter_input(INPUT_GET, 'p') produces false.

Now how do I get the array value of p using filter_input

3 Answers 3

6

As the documentation say, you should use the FILTER_REQUIRE_ARRAY flag:

filter_input(INPUT_GET, 'p', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY)
Sign up to request clarification or add additional context in comments.

Comments

2

Is it always going to be be an array? If so, filter_input_array could work for you: https://secure.php.net/manual/en/function.filter-input-array.php

Something like this should do the trick (untested):

$data = filter_input(INPUT_GET, 'p', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);

Comments

1

Maybe you could use:

print_r( filter_input_array ( INPUT_GET ));

http://php.net/manual/en/function.filter-input-array.php

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.