public static function nest(array $data, $seperator = '_')
    {
        if (self::isAssoc($data)) {
            $result = new \stdClass();

            foreach ($data as $key => $value) {
                if (($pos = strpos($key, $seperator)) !== false) {
                    $subKey = substr($key, 0, $pos);
                    $name   = substr($key, $pos + 1);

                    if (!isset($result->{$subKey})) {
                        $result->{$subKey} = self::nest(self::getParts($data, $subKey . $seperator), $seperator);
                    }
                } else {
                    $result->{$key} = $value;
                }
            }

            return $result;
        } else {
            $result = [];

            foreach ($data as $value) {
                $result[] = self::nest($value, $seperator);
            }

            return $result;
        }
    }
public static function nest(array $data, $seperator = '_')
    {
        if (self::isAssoc($data)) {
            $result = new \stdClass();

            foreach ($data as $key => $value) {
                if (($pos = strpos($key, $seperator)) !== false) {
                    $subKey = substr($key, 0, $pos);
                    $name   = substr($key, $pos + 1);

                    if (!isset($result->{$subKey})) {
                        $result->{$subKey} = self::nest(self::getParts($data, $subKey . $seperator), $seperator);
                    }
                } else {
                    $result->{$key} = $value;
                }
            }

            return $result;
        } else {
            $result = [];

            foreach ($data as $value) {
                $result[] = self::nest($value, $seperator);
            }

            return $result;
        }
    }
public static function nest ( array $ data , $ seperator = '_' ) { if ( self :: isAssoc ( $ data ) ) { $ result = new \ stdClass ( ) ; foreach ( $ data as $ key => $ value ) { if ( ( $ pos = strpos ( $ key , $ seperator ) ) !== false ) { $ subKey = substr ( $ key , 0 , $ pos ) ; $ name = substr ( $ key , $ pos + 1 ) ; if ( ! isset ( $ result -> { $ subKey } ) ) { $ result -> { $ subKey } = self :: nest ( self :: getParts ( $ data , $ subKey . $ seperator ) , $ seperator ) ; } } else { $ result -> { $ key } = $ value ; } } return $ result ; } else { $ result = [ ] ; foreach ( $ data as $ value ) { $ result [ ] = self :: nest ( $ value , $ seperator ) ; } return $ result ; } }
Converts a flat array into a nested object using a seperator

@param array $data
@param string $seperator
@return \stdClass
Converts a flat array into a nested object using a seperator