lib/GoCardless/Utils.php
public static function generate_query_string($params, &$pairs = array(),
    $namespace = null) {

    if (is_array($params)) {

      foreach ($params as $k => $v) {

        if (is_int($k)) {
          GoCardless_Utils::generate_query_string($v, $pairs, $namespace .
            '[]');
        } else {
          GoCardless_Utils::generate_query_string($v, $pairs,
            $namespace !== null ? $namespace . "[$k]" : $k);
        }

      }

      if ($namespace !== null) {
        return $pairs;
      }

      if (empty($pairs)) {
        return '';
      }

      usort($pairs, array(__CLASS__, 'sortPairs'));

      $strs = array();
      foreach ($pairs as $pair) {
        $strs[] = $pair[0] . '=' . $pair[1];
      }

      return implode('&', $strs);

    } else {

      $pairs[] = array(rawurlencode($namespace), rawurlencode($params));

    }

  }
public static function generate_query_string($params, &$pairs = array(),
    $namespace = null) {

    if (is_array($params)) {

      foreach ($params as $k => $v) {

        if (is_int($k)) {
          GoCardless_Utils::generate_query_string($v, $pairs, $namespace .
            '[]');
        } else {
          GoCardless_Utils::generate_query_string($v, $pairs,
            $namespace !== null ? $namespace . "[$k]" : $k);
        }

      }

      if ($namespace !== null) {
        return $pairs;
      }

      if (empty($pairs)) {
        return '';
      }

      usort($pairs, array(__CLASS__, 'sortPairs'));

      $strs = array();
      foreach ($pairs as $pair) {
        $strs[] = $pair[0] . '=' . $pair[1];
      }

      return implode('&', $strs);

    } else {

      $pairs[] = array(rawurlencode($namespace), rawurlencode($params));

    }

  }
Generates, encodes, re-orders variables for the query string.

@param array $params The specific parameters for this payment
@param array $pairs Pairs
@param string $namespace The namespace

@return string An encoded string of parameters