Get the nid from current URL after the ? for views argument I am adding a post to an Organic Group and I want to display a list of all posts to that group below the node add form. The url looks like this:

    node/add/group_post?gids[]=23


I want to add argument that filters the view using the group's id. How can I use the PHP to get that gid?

This is what I have so far, but it's not working.

    $gid = htmlspecialchars($_GET["gids[]"]);
    return $gid;
Just put $_GET['gids'] this will return you an array in PHP.
Then if there's only one nid you can make:

$gids = $_GET['gids'];
return $gids[0];


Source: How to get PHP $_GET array?