simple_html_dom::remove_noise PHP Method

remove_noise() protected method

remove noise from html content
protected remove_noise ( $pattern, $remove_tag = false )
    protected function remove_noise($pattern, $remove_tag = false)
    {
        $count = preg_match_all($pattern, $this->doc, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE);
        for ($i = $count - 1; $i > -1; --$i) {
            $key = '___noise___' . sprintf('% 3d', count($this->noise) + 100);
            $idx = $remove_tag ? 0 : 1;
            $this->noise[$key] = $matches[$i][$idx][0];
            $this->doc = substr_replace($this->doc, $key, $matches[$i][$idx][1], strlen($matches[$i][$idx][0]));
        }
        // reset the length of content
        $this->size = strlen($this->doc);
        if ($this->size > 0) {
            $this->char = $this->doc[0];
        }
    }