arg

5 path.inc arg($index)
6 path.inc arg($index = NULL, $path = NULL)
7 bootstrap.inc arg($index = NULL, $path = NULL)
8 bootstrap.inc arg($index = NULL, $path = NULL)

Return a component of the current Drupal path.

When viewing a page at the path "admin/content/types", for example, arg(0) would return "admin", arg(1) would return "content", and arg(2) would return "types".

Avoid use of this function where possible, as resulting code is hard to read. Instead, attempt to use named arguments in menu callback functions. See the explanation in menu.inc for how to construct callbacks that take arguments.

Parameters

$index: The index of the component, where each component is separated by a '/' (forward-slash), and where the first component has an index of 0 (zero).

Return value

The component specified by $index, or FALSE if the specified component was not found.

71 calls to arg()

File

includes/path.inc, line 147
Functions to handle paths in Drupal, including path aliasing.

Code

function arg($index) {
  static $arguments, $q;

  if (empty($arguments) || $q != $_GET['q']) {
    $arguments = explode('/', $_GET['q']);
    $q = $_GET['q'];
  }

  if (isset($arguments[$index])) {
    return $arguments[$index];
  }
}
Login or register to post comments