drupal_query_string_encode

Versions
5 – 6
drupal_query_string_encode($query, $exclude = array(), $parent = '')

Parse an array into a valid urlencoded query string.

Parameters

$query The array to be processed e.g. $_GET

$exclude The array filled with keys to be excluded. Use parent[child] to exclude nested items.

$parent Should not be passed, only used in recursive calls

Return value

urlencoded string which can be appended to/as the URL query string

▾ 7 functions call drupal_query_string_encode()

apachesolr_l in contributions/apachesolr/apachesolr.module
A replacement for l()
apachesolr_search_form_search_submit in contributions/apachesolr/apachesolr_search.module
Added form submit function to account for Apache mode_rewrite quirks.
drupal_get_destination in drupal/includes/common.inc
Prepare a destination query string for use in combination with drupal_goto(). Used to direct the user back to the referring page after completing a form. By default the current URL is returned. If a destination exists in the previous request, that…
drupal_query_string_encode in drupal/includes/common.inc
Parse an array into a valid urlencoded query string.
pager_get_querystring in drupal/includes/pager.inc
Compose a query string to append to pager requests.
tablesort_get_querystring in drupal/includes/tablesort.inc
Compose a query string to append to table sorting requests.
theme_pager_link in drupal/includes/pager.inc
Format a link to a specific query result page.

Code

drupal/includes/common.inc, line 213

<?php
function drupal_query_string_encode($query, $exclude = array(), $parent = '') {
  $params = array();

  foreach ($query as $key => $value) {
    $key = drupal_urlencode($key);
    if ($parent) {
      $key = $parent .'['. $key .']';
    }

    if (in_array($key, $exclude)) {
      continue;
    }

    if (is_array($value)) {
      $params[] = drupal_query_string_encode($value, $exclude, $key);
    }
    else {
      $params[] = $key .'='. drupal_urlencode($value);
    }
  }

  return implode('&', $params);
}
?>

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.