protected function flattenParts(array $parts, array $flattened = [], $pre = '', $idx = 1, $full = true)
    {
        foreach ($parts as $part) {
            $key = $pre.$idx;
            $flattened[$key] = $part;
            if (isset($part->parts)) {
    			if ($part->type == TYPEMULTIPART) {
    				$flattened = $this->flattenParts($part->parts, $flattened, $key.'.', 1, false);
    			} elseif ($full) {
    				$flattened = $this->flattenParts($part->parts, $flattened, $key.'.');
    			} else {
    				$flattened = $this->flattenParts($part->parts, $flattened, $pre);
    			}
    			unset($flattened[$key]->parts);
    		}
    		$idx++;
        }

        return $flattened;
    }
protected function flattenParts(array $parts, array $flattened = [], $pre = '', $idx = 1, $full = true)
    {
        foreach ($parts as $part) {
            $key = $pre.$idx;
            $flattened[$key] = $part;
            if (isset($part->parts)) {
    			if ($part->type == TYPEMULTIPART) {
    				$flattened = $this->flattenParts($part->parts, $flattened, $key.'.', 1, false);
    			} elseif ($full) {
    				$flattened = $this->flattenParts($part->parts, $flattened, $key.'.');
    			} else {
    				$flattened = $this->flattenParts($part->parts, $flattened, $pre);
    			}
    			unset($flattened[$key]->parts);
    		}
    		$idx++;
        }

        return $flattened;
    }
protected function flattenParts ( array $ parts , array $ flattened = [ ] , $ pre = '' , $ idx = 1 , $ full = true ) { foreach ( $ parts as $ part ) { $ key = $ pre . $ idx ; $ flattened [ $ key ] = $ part ; if ( isset ( $ part -> parts ) ) { if ( $ part -> type == TYPEMULTIPART ) { $ flattened = $ this -> flattenParts ( $ part -> parts , $ flattened , $ key . '.' , 1 , false ) ; } elseif ( $ full ) { $ flattened = $ this -> flattenParts ( $ part -> parts , $ flattened , $ key . '.' ) ; } else { $ flattened = $ this -> flattenParts ( $ part -> parts , $ flattened , $ pre ) ; } unset ( $ flattened [ $ key ] -> parts ) ; } $ idx ++ ; } return $ flattened ; }
Flatten email structure recursively.

Parts re-keyed as 1, 1.1, 2, 2.1, 2.1.1 etc

@param  array $parts
@param  array $flattened
@param  string $pre
@param  int $idx
@param  bool $full
@return array
Flatten email structure recursively .