private static function parseQuery($str, $urlEncoding = true)
    {
        $result = [];
        if ($str === '') {
            return $result;
        }
        if ($urlEncoding === true) {
            $decoder = function ($value) {
                return rawurldecode(str_replace('+', ' ', $value));
            };
        } elseif ($urlEncoding == PHP_QUERY_RFC3986) {
            $decoder = 'rawurldecode';
        } elseif ($urlEncoding == PHP_QUERY_RFC1738) {
            $decoder = 'urldecode';
        } else {
            $decoder = function ($str) { return $str; };
        }
        foreach (explode('&', $str) as $kvp) {
            $parts = explode('=', $kvp, 2);
            $key = $decoder($parts[0]);
            $value = isset($parts[1]) ? $decoder($parts[1]) : null;
            if (!isset($result[$key])) {
                $result[$key] = $value;
            } else {
                if (!is_array($result[$key])) {
                    $result[$key] = [$result[$key]];
                }
                $result[$key][] = $value;
            }
        }
        return $result;
    }
private static function parseQuery($str, $urlEncoding = true)
    {
        $result = [];
        if ($str === '') {
            return $result;
        }
        if ($urlEncoding === true) {
            $decoder = function ($value) {
                return rawurldecode(str_replace('+', ' ', $value));
            };
        } elseif ($urlEncoding == PHP_QUERY_RFC3986) {
            $decoder = 'rawurldecode';
        } elseif ($urlEncoding == PHP_QUERY_RFC1738) {
            $decoder = 'urldecode';
        } else {
            $decoder = function ($str) { return $str; };
        }
        foreach (explode('&', $str) as $kvp) {
            $parts = explode('=', $kvp, 2);
            $key = $decoder($parts[0]);
            $value = isset($parts[1]) ? $decoder($parts[1]) : null;
            if (!isset($result[$key])) {
                $result[$key] = $value;
            } else {
                if (!is_array($result[$key])) {
                    $result[$key] = [$result[$key]];
                }
                $result[$key][] = $value;
            }
        }
        return $result;
    }
private static function parseQuery ( $ str , $ urlEncoding = true ) { $ result = [ ] ; if ( $ str === '' ) { return $ result ; } if ( $ urlEncoding === true ) { $ decoder = function ( $ value ) { return rawurldecode ( str_replace ( '+' , ' ' , $ value ) ) ; } ; } elseif ( $ urlEncoding == PHP_QUERY_RFC3986 ) { $ decoder = 'rawurldecode' ; } elseif ( $ urlEncoding == PHP_QUERY_RFC1738 ) { $ decoder = 'urldecode' ; } else { $ decoder = function ( $ str ) { return $ str ; } ; } foreach ( explode ( '&' , $ str ) as $ kvp ) { $ parts = explode ( '=' , $ kvp , 2 ) ; $ key = $ decoder ( $ parts [ 0 ] ) ; $ value = isset ( $ parts [ 1 ] ) ? $ decoder ( $ parts [ 1 ] ) : null ; if ( ! isset ( $ result [ $ key ] ) ) { $ result [ $ key ] = $ value ; } else { if ( ! is_array ( $ result [ $ key ] ) ) { $ result [ $ key ] = [ $ result [ $ key ] ] ; } $ result [ $ key ] [ ] = $ value ; } } return $ result ; }
Parse a query string into an associative array.

If multiple values are found for the same key, the value of that key
value pair will become an array. This function does not parse nested
PHP style arrays into an associative array (e.g., foo[a]=1&foo[b]=2 will
be parsed into ['foo[a]' => '1', 'foo[b]' => '2']).

@param string      $str         Query string to parse
@param bool|string $urlEncoding How the query string is encoded

@return array
Parse a query string into an associative array .