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]
.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With