public static function expand(array $data, $separator = '.')
    {
        $result = [];
        foreach ($data as $flat => $value) {
            $keys = explode($separator, $flat);
            $keys = array_reverse($keys);
            $child = [
            $keys[0] => $value
            ];
            array_shift($keys);
            foreach ($keys as $k) {
                $child = [
                $k => $child
                ];
            }

            $stack = [[$child, &$result]];
            static::mergeHelper($stack, $result);
        }

        return $result;
    }
public static function expand(array $data, $separator = '.')
    {
        $result = [];
        foreach ($data as $flat => $value) {
            $keys = explode($separator, $flat);
            $keys = array_reverse($keys);
            $child = [
            $keys[0] => $value
            ];
            array_shift($keys);
            foreach ($keys as $k) {
                $child = [
                $k => $child
                ];
            }

            $stack = [[$child, &$result]];
            static::mergeHelper($stack, $result);
        }

        return $result;
    }
public static function expand ( array $ data , $ separator = '.' ) { $ result = [ ] ; foreach ( $ data as $ flat => $ value ) { $ keys = explode ( $ separator , $ flat ) ; $ keys = array_reverse ( $ keys ) ; $ child = [ $ keys [ 0 ] => $ value ] ; array_shift ( $ keys ) ; foreach ( $ keys as $ k ) { $ child = [ $ k => $ child ] ; } $ stack = [ [ $ child , & $ result ] ] ; static :: mergeHelper ( $ stack , $ result ) ; } return $ result ; }
Expands a flat array to a nested array.

For example, unflattens an array that was collapsed with `Hash::flatten()`
into a multi-dimensional array. So, `['0.Foo.Bar' => 'Far']` becomes
`[['Foo' => ['Bar' => 'Far']]]`.

@param array $data Flattened array.
@param string $separator The delimiter used.

@return array
Expands a flat array to a nested array .