Same name and namespace in other branches
  1. 4.7.x includes/path.inc \arg()
  2. 5.x includes/path.inc \arg()
  3. 6.x includes/path.inc \arg()
  4. 7.x includes/bootstrap.inc \arg()

Return a component of the current Drupal path.

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

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.

36 calls to arg()
aggregator_edit in modules/aggregator.module
aggregator_page_category in modules/aggregator.module
Menu callback; displays all the items aggregated in a particular category.
aggregator_page_last in modules/aggregator.module
Menu callback; displays the most recent items gathered from any feed.
aggregator_page_source in modules/aggregator.module
Menu callback; displays all the items captured from a particular feed.
block_list in modules/block.module
Return all blocks in the specied region for the current user. You may use this function to implement variable block regions. The default regions are 'left', 'right' and 'all', where 'all' means both left and right.

... See full list

File

includes/bootstrap.inc, line 527
Functions that need to be loaded on every Drupal request.

Code

function arg($index) {
  static $arguments, $q;
  if (empty($arguments) || $q != $_GET['q']) {
    $arguments = explode('/', $_GET['q']);
  }
  if (array_key_exists($index, $arguments)) {
    return $arguments[$index];
  }
}