src/Str.php
private function buildDimensionalArray(array $keys, $dimensions, $value)
    {
        $result = [];

        // add first dimension
        $result[$keys[0]] = [];
        $pointer = &$result[$keys[0]];

        for ($i = 1; $i < $dimensions; $i++) {
            if ($i === ($dimensions - 1)) {
                $pointer[$keys[$i]] = $value;
            } else {
                $pointer[$keys[$i]] = [];
                $pointer = &$pointer[$keys[$i]];
            }
        }

        return $result;
    }
private function buildDimensionalArray(array $keys, $dimensions, $value)
    {
        $result = [];

        // add first dimension
        $result[$keys[0]] = [];
        $pointer = &$result[$keys[0]];

        for ($i = 1; $i < $dimensions; $i++) {
            if ($i === ($dimensions - 1)) {
                $pointer[$keys[$i]] = $value;
            } else {
                $pointer[$keys[$i]] = [];
                $pointer = &$pointer[$keys[$i]];
            }
        }

        return $result;
    }
Builds nested array with the specified keys.

@param array $keys
@param int $dimensions
@param string $value

@return array