Pass an array using keys through HTTP GET

I tried passing the array data to a PHP script with the request:

script.php?page=7&filter[key]=value

but did not get it in the script. Can I do this, and if not, how can I pass an array using an HTTP GET?

+4
source share
3 answers

You can definitely pass the array from url and get the value in the php page,

$testvar = $_GET['filter'];
echo $testvar['key'];

and just out of curiosity I tried $_GET['filter']['value'], and it works too !!!

and if you want to pass multiple vals arrays you can use http_build_query

+1
source

Yes, you will get this value in an array on the page script.php

Just try printing the value of the array on the page script.php.

print_r($_GET['filter']);

+1
source

,

script.php?page=7&filter=value

is_array() ,

is_array($_GET['filter'])

http://php.net/manual/en/function.is-array.php

0

All Articles