You are here

function Net_URL::_parseRawQuerystring in Flickr API 5

Parses raw querystring and returns an array of it

@access private

Parameters

string $querystring The querystring to parse:

Return value

array An array of the querystring data

1 call to Net_URL::_parseRawQuerystring()
Net_URL::__construct in phpFlickr/PEAR/Net/URL.php
PHP5 Constructor

File

phpFlickr/PEAR/Net/URL.php, line 300

Class

Net_URL

Code

function _parseRawQuerystring($querystring) {
  $parts = preg_split('/[' . preg_quote(ini_get('arg_separator.input'), '/') . ']/', $querystring, -1, PREG_SPLIT_NO_EMPTY);
  $return = array();
  foreach ($parts as $part) {
    if (strpos($part, '=') !== false) {
      $value = substr($part, strpos($part, '=') + 1);
      $key = substr($part, 0, strpos($part, '='));
    }
    else {
      $value = null;
      $key = $part;
    }
    if (substr($key, -2) == '[]') {
      $key = substr($key, 0, -2);
      if (@(!is_array($return[$key]))) {
        $return[$key] = array();
        $return[$key][] = $value;
      }
      else {
        $return[$key][] = $value;
      }
    }
    elseif (!$this->useBrackets and !empty($return[$key])) {
      $return[$key] = (array) $return[$key];
      $return[$key][] = $value;
    }
    else {
      $return[$key] = $value;
    }
  }
  return $return;
}