protected function addNestedValue(string $key, $value, int $pos)
    {
        # convert the levels into an array of strings
        $levels = (strpos($key, "][") !== false)
            ? explode("][", substr($key, $pos + 1, -1))
            : [substr($key, $pos + 1, -1)];

        array_unshift($levels, substr($key, 0, $pos));

        # ensure the nesting doesn't exceed `max_nesting_levels`
        $levelLen = count($levels);
        if ($levelLen > $this->maxNestingLevels) {
            throw new DecodeException("max_input_nesting_level exceeded");
        }

        $lastKey = array_pop($levels);
        $values = &$this->values;
        foreach ($levels as $level) {
            if ($level === "") {
                $level = count($values);
            }
            if (!array_key_exists($level, $values)) {
                $values[$level] = [];
            }
            $values = &$values[$level];
        }

        if ($lastKey === "") {
            $lastKey = count($values);
        }

        \sndsgd\Arr::addValue($values, $lastKey, $value);
    }
protected function addNestedValue(string $key, $value, int $pos)
    {
        # convert the levels into an array of strings
        $levels = (strpos($key, "][") !== false)
            ? explode("][", substr($key, $pos + 1, -1))
            : [substr($key, $pos + 1, -1)];

        array_unshift($levels, substr($key, 0, $pos));

        # ensure the nesting doesn't exceed `max_nesting_levels`
        $levelLen = count($levels);
        if ($levelLen > $this->maxNestingLevels) {
            throw new DecodeException("max_input_nesting_level exceeded");
        }

        $lastKey = array_pop($levels);
        $values = &$this->values;
        foreach ($levels as $level) {
            if ($level === "") {
                $level = count($values);
            }
            if (!array_key_exists($level, $values)) {
                $values[$level] = [];
            }
            $values = &$values[$level];
        }

        if ($lastKey === "") {
            $lastKey = count($values);
        }

        \sndsgd\Arr::addValue($values, $lastKey, $value);
    }
protected function addNestedValue ( string $ key , $ value , int $ pos ) { # convert the levels into an array of strings $ levels = ( strpos ( $ key , "][" ) !== false ) ? explode ( "][" , substr ( $ key , $ pos + 1 , - 1 ) ) : [ substr ( $ key , $ pos + 1 , - 1 ) ] ; array_unshift ( $ levels , substr ( $ key , 0 , $ pos ) ) ; # ensure the nesting doesn't exceed `max_nesting_levels` $ levelLen = count ( $ levels ) ; if ( $ levelLen > $ this -> maxNestingLevels ) { throw new DecodeException ( "max_input_nesting_level exceeded" ) ; } $ lastKey = array_pop ( $ levels ) ; $ values = & $ this -> values ; foreach ( $ levels as $ level ) { if ( $ level === "" ) { $ level = count ( $ values ) ; } if ( ! array_key_exists ( $ level , $ values ) ) { $ values [ $ level ] = [ ] ; } $ values = & $ values [ $ level ] ; } if ( $ lastKey === "" ) { $ lastKey = count ( $ values ) ; } \ sndsgd \ Arr :: addValue ( $ values , $ lastKey , $ value ) ; }
Add a value that has a nested key

@param string $key
@param mixed $value
@param integer $pos The position of the first open bracket
Add a value that has a nested key