function drupal_query_string_encode
6.x common.inc | 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
An urlencoded string which can be appended to/as the URL query string.
Related topics
5 calls to drupal_query_string_encode()
- drupal_get_destination in drupal-6.x/
includes/ common.inc - Prepare a destination query string for use in combination with drupal_goto().
- pager_get_querystring in drupal-6.x/
includes/ pager.inc - Compose a query string to append to pager requests.
- tablesort_get_querystring in drupal-6.x/
includes/ tablesort.inc - Compose a query string to append to table sorting requests.
- theme_pager_link in drupal-6.x/
includes/ pager.inc - Returns HTML for a link to a specific query result page.
- url in drupal-6.x/
includes/ common.inc - Generates an internal or external URL.
File
- drupal-6.x/
includes/ common.inc, line 227 - Common functions that many Drupal modules will need to reference.
Code
function drupal_query_string_encode($query, $exclude = array(), $parent = '') {
$params = array();
foreach ($query as $key => $value) {
$key = rawurlencode($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 . '=' . rawurlencode($value);
}
}
return implode('&', $params);
}