protected function removeElement($element, $contents)
    {
        $newContents = preg_replace('@'.$element->regex.'@xi', '', $contents);

        if ($newContents !== $contents && isset($element->elements)) {
            foreach ($element->elements as $element) {
                $newContents = $this->removeElement($element, $newContents);
            }
        }

        return $newContents;
    }
protected function removeElement($element, $contents)
    {
        $newContents = preg_replace('@'.$element->regex.'@xi', '', $contents);

        if ($newContents !== $contents && isset($element->elements)) {
            foreach ($element->elements as $element) {
                $newContents = $this->removeElement($element, $newContents);
            }
        }

        return $newContents;
    }
protected function removeElement ( $ element , $ contents ) { $ newContents = preg_replace ( '@' . $ element -> regex . '@xi' , '' , $ contents ) ; if ( $ newContents !== $ contents && isset ( $ element -> elements ) ) { foreach ( $ element -> elements as $ element ) { $ newContents = $ this -> removeElement ( $ element , $ newContents ) ; } } return $ newContents ; }
Remove an optional element.

@param object $element
@param string $contents

@return string
Remove an optional element .