I have the following URL
http://www.example.com/node/add/forum/3?gids[]=13
I want to get the value 13 from within my module.
I've tried with
$_GET['gid[]']
and with
$_GET['gids%5B%5D']
but I always get null.
How can I do this? Thanks
I have the following URL
http://www.example.com/node/add/forum/3?gids[]=13
I want to get the value 13 from within my module.
I've tried with
$_GET['gid[]']
and with
$_GET['gids%5B%5D']
but I always get null.
How can I do this? Thanks
Assuming the URL is correctly encoded (gids%5B%5D) and that's the only element in the array, then the contents of that first element in gids would be in $_GET['gids'][0].
arg(), which only deals with the path query string variable ($_GET['q']). Updated to remove the bit about dealing with all $_GET variables.Since this is tagged with the keyword "drupal" and comes up on Google searches. The Drupal 7 way of doing it and makes it easy is to use drupal_get_query_parameters(). This will return an associate array of all variables and values from the query string all at once.
By using this, when you store the information coming from the URL it has been sanitized for XSS and SQLi attacks.
In PHP 5.2+, use filter_input() to read GET and POST variables:
$gids = filter_input(INPUT_GET, 'gids', FILTER_DEFAULT, FILTER_FORCE_ARRAY | FILTER_FORCE_ARRAY);