How to get group id from custom url I have some more custom url with og group id like 


www.example.com/students/6593
www.example.com/results/6953
www.example.com/book-listing/5367/6953

here 6953 is a group id.


these are the sample link. my questions is how to get the group id from url? And i can't use arg(). because i have more no of url and group id position also varied.

There is any robust solutions for this.
I have used the following code in hook_preprocess_page() to solve this issue.

$url = current_path();
  $arguments = explode('/', $url);
  foreach ($arguments as $value) {
    if (is_numeric($value)) {
      $node = node_load($value);
      if (og_is_group('node', $node)) {
        drupal_set_message('group id :' . $node-&gt;nid);
      }
    }
  }


From now, i can set to group member only could see this page.