Flatten a multi-dimensional array by returning the values with their keys representing their previous pathing.

@param array $set
@param string $path
@return array
432331
public static function flatten(array $set, $path = null) {
        if ($path) {
            $path = $path . '.';
        }

        $data = array();

        foreach ($set as $key => $value) {
            if (is_array($value)) {
                if ($value) {
                    $data += static::flatten($value, $path . $key);
                } else {
                    $data[$path . $key] = null;
                }
            } else {
                $data[$path . $key] = $value;
            }
        }

        return $data;
    }
1294703
private function buildPath($path)
    {
        $result = [];
        foreach (explode('/', $path) as $value) {
            if (!empty($value)) {
                $result[] = (int) $value;
            }
        }
        return $result;
    }
539679
public static function flatten($array, $depth = INF)
    {
        $result = [];

        foreach ($array as $item) {
            $item = $item instanceof Collection ? $item->all() : $item;

            if (is_array($item)) {
                if ($depth === 1) {
                    $result = array_merge($result, $item);
                    continue;
                }

                $result = array_merge($result, static::flatten($item, $depth - 1));
                continue;
            }

            $result[] = $item;
        }

        return $result;
    }
784498
public function flattenArrayByKey(array $data, $key)
    {
        $array = [];
        foreach ($data as $value) {
            if (is_array($value) && isset($value[$key])) {
                $array[] = $value[$key];
            }
        }

        return $array;
    }
674417
public function pathSet( $path, $value )
	{
		$path = $this->createPath($path);
		if( $path[0] == 1 )
		{
			$this->offsetSet($path[1], $value);
		}
		else
		{
			$array = & $this->items;
			for( $i = 1, $len = $path[0]; $i <= $len; $i++ )
			{
				$key = $path[$i];
				if( $i == $len )
				{
					$array[$key] = $value;
				}
				else
				{
					if( !isset($array[$key]) || !is_array($array[$key]) )
					{
						$array[$key] = [];
					}

					$array = & $array[$key];
				}
			}
		}
		return $this;
	}
1355642
protected function getFileKeys($path, array $keys)
    {
        if (!$this->hasFile($path)) {
            return false;
        }

        return $this->getKeys($path, $keys);
    }
500370
protected function getKeys($path, array $keys)
    {
        if (!$this->has($path)) {
            return false;
        }

        $return = [];
        foreach ($keys as $key) {
            if ($key === 'path') {
                $return[$key] = $path;
                continue;
            }

            $return[$key] = $this->storage[$path][$key];
        }

        return $return;
    }
118379
static function arrayGetByPath($array, $path) {
        list($container, $subpath) = self::getSelectorParts($path);
        if ($subpath === '') {
            return array_key_exists($container, $array) ? $array[$container] : null;
        }
        return array_key_exists($container, $array) ? self::arrayGetByPath($array[$container], $subpath) : null;
    }
992273
public function flatten(?string $key = null) : array
    {
        $array = new \RecursiveIteratorIterator(
            new \RecursiveArrayIterator((array) $this->get($key))
        );

        $tmp = [];
        foreach ($array as $value) {
            $tmp[] = $value;
        }

        return $tmp;
    }
1228727
protected static function _makeDimensional($path, $value){
		$a = [];
		$temp = &$a;
		foreach ( $path as $key ) {
			$temp = &$temp[$key];
		}
		$temp = $value;
		return $a;
	}
892408
public static function getByPath($array, $path = self::PATH_ROOT)
    {
        $path = trim($path);
        if (! $path || $path == self::PATH_ROOT) {
            return $array;
        }
        // fix the path in case it was provided as `[item][subitem]`
        if (strpos($path, '[') === 0) {
            $path = preg_replace('/]/', '', ltrim($path, '['), 1);
        }

        list($container, $subpath) = self::getSelectorParts($path);
        if ($subpath === '') {
            return array_key_exists($container, $array) ? $array[$container] : null;
        }

        return array_key_exists($container, $array) ? self::getByPath($array[$container], $subpath) : null;
    }
1110967
public static function flatten($array = [])
    {
        $items = [];
        foreach ($array as $value) {
            if (is_array($value)) {
                $items = array_merge($items, self::flatten($value));
            } else {
                $items[] = $value;
            }
        }
        return $items;
    }
1333361
private function relativizePaths($path)
    {
        if (!$this->basePath) {
            return $path;
        }

        return str_replace($this->basePath . DIRECTORY_SEPARATOR, '', $path);
    }
101649
protected function mapArray(array $array, array $path, array $params)
	{
		$key  = array_shift($path);
		$keys = ($key === '*') ? array_keys($array) : [$key];
		foreach ($keys as $key)
		{
			if (!isset($array[$key]))
			{
				continue;
			}
			$array[$key] = (empty($path)) ? $this->generateFunction($array[$key], $params) : $this->mapArray($array[$key], $path, $params);
		}

		return $array;
	}
603177
protected function splitPath($path)
    {
        $chunks = array_map(
            [$this, 'unescape'],
            preg_split('#(?<!\\\)\/#', ltrim($path, '/'))
        );

        if (empty($chunks) || (array_filter($chunks) !== $chunks)) {
            throw new \InvalidArgumentException('Invalid path provided:' . $path);
        }

        return $chunks;
    }
721282
public static function flatten (array $sequence)
    {
        $flat = array();
        array_walk_recursive($sequence, function ($element) use (&$flat) { $flat []= $element; });
        return $flat;
    }
686537
protected function flattenArray(array $values, $previous = '')
    {
        $result = array();
        foreach ($values as $key => $value) {
            if ($previous) {
                $key = $previous.'['.$key.']';
            }
            if (is_array($value)) {
                $result = $result + $this->flattenArray($value, $key);
            } else {
                $result[$key] = $value;
            }
        }

        return $result;
    }