public static function QueryString::aggregateUsingPhp

Aggregate multi-valued parameters using PHP style syntax

Parameters

string $key The name of the query string parameter:

array $value The values of the parameter:

bool $encode Set to TRUE to encode field names and values:

Return value

array Returns an array of the combined values

File

drupal/core/vendor/guzzle/http/Guzzle/Http/QueryString.php, line 117

Class

QueryString
Query string object to handle managing query string parameters and aggregating those parameters together as a string.

Namespace

Guzzle\Http

Code

public static function aggregateUsingPhp($key, array $value, $encode = false) {
  $ret = array();
  foreach ($value as $k => $v) {
    $k = "{$key}[{$k}]";
    if (is_array($v)) {
      $ret = array_merge($ret, self::aggregateUsingPhp($k, $v, $encode));
    }
    else {
      if ($encode) {
        $ret[rawurlencode($k)] = rawurlencode($v);
      }
      else {
        $ret[$k] = $v;
      }
    }
  }
  return $ret;
}