src/Net/URL2.php
private function _queryArrayByBrackets($buffer, $value, array $array = null)
    {
        $entry = &$array;

        for ($iteration = 0; strlen($buffer); $iteration++) {
            $open = $this->_queryKeyBracketOffset($buffer);
            if ($open !== 0) {
                // Opening bracket [ must exist at offset 0, if not, there is
                // no bracket to parse and the value dropped.
                // if this happens in the first iteration, this is flawed, see
                // as well the second exception below.
                if ($iteration) {
                    break;
                }
                // @codeCoverageIgnoreStart
                throw new Exception(
                    'Net_URL2 Internal Error: '. __METHOD__ .'(): ' .
                    'Opening bracket [ must exist at offset 0'
                );
                // @codeCoverageIgnoreEnd
            }

            $close = strpos($buffer, ']', 1);
            if (!$close) {
                // this error condition should never be reached as this is a
                // private method and bracket pairs are checked beforehand.
                // See as well the first exception for the opening bracket.
                // @codeCoverageIgnoreStart
                throw new Exception(
                    'Net_URL2 Internal Error: '. __METHOD__ .'(): ' .
                    'Closing bracket ] must exist, not found'
                );
                // @codeCoverageIgnoreEnd
            }

            $index = substr($buffer, 1, $close - 1);
            if (strlen($index)) {
                $entry = &$entry[$index];
            } else {
                if (!is_array($entry)) {
                    $entry = array();
                }
                $entry[] = &$new;
                $entry = &$new;
                unset($new);
            }
            $buffer = substr($buffer, $close + 1);
        }

        $entry = $value;

        return $array;
    }
private function _queryArrayByBrackets($buffer, $value, array $array = null)
    {
        $entry = &$array;

        for ($iteration = 0; strlen($buffer); $iteration++) {
            $open = $this->_queryKeyBracketOffset($buffer);
            if ($open !== 0) {
                // Opening bracket [ must exist at offset 0, if not, there is
                // no bracket to parse and the value dropped.
                // if this happens in the first iteration, this is flawed, see
                // as well the second exception below.
                if ($iteration) {
                    break;
                }
                // @codeCoverageIgnoreStart
                throw new Exception(
                    'Net_URL2 Internal Error: '. __METHOD__ .'(): ' .
                    'Opening bracket [ must exist at offset 0'
                );
                // @codeCoverageIgnoreEnd
            }

            $close = strpos($buffer, ']', 1);
            if (!$close) {
                // this error condition should never be reached as this is a
                // private method and bracket pairs are checked beforehand.
                // See as well the first exception for the opening bracket.
                // @codeCoverageIgnoreStart
                throw new Exception(
                    'Net_URL2 Internal Error: '. __METHOD__ .'(): ' .
                    'Closing bracket ] must exist, not found'
                );
                // @codeCoverageIgnoreEnd
            }

            $index = substr($buffer, 1, $close - 1);
            if (strlen($index)) {
                $entry = &$entry[$index];
            } else {
                if (!is_array($entry)) {
                    $entry = array();
                }
                $entry[] = &$new;
                $entry = &$new;
                unset($new);
            }
            $buffer = substr($buffer, $close + 1);
        }

        $entry = $value;

        return $array;
    }
Parse a key-buffer to place value in array

@param string $buffer to consume all keys from
@param string $value  to be set/add
@param array  $array  to traverse and set/add value in

@throws Exception
@return array