Reputation: 33090
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
Upvotes: 2
Views: 1460
Reputation: 11328
Maybe you could use:
print_r( filter_input_array ( INPUT_GET ));
http://php.net/manual/en/function.filter-input-array.php
Upvotes: 1
Reputation: 6139
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);
Upvotes: 2
Reputation: 36944
As the documentation say, you should use the FILTER_REQUIRE_ARRAY
flag:
filter_input(INPUT_GET, 'p', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY)
Upvotes: 6