Imdb\Person::parsearticles PHP Method

parsearticles() protected method

Helper for article parsing
See also: IMDB person page /publicity
protected parsearticles ( &$res, $page, $title )
    protected function parsearticles(&$res, $page, $title)
    {
        $this->getPage($page);
        $pos_s = strpos($this->page[$page], "<h5>{$title}</h5>");
        if ($pos_s === FALSE) {
            $res = array();
            return;
        }
        $pos_e = strpos($this->page[$page], "</table", $pos_s);
        $block = substr($this->page[$page], $pos_s, $pos_e - $pos_s);
        @preg_match_all("|<tr>(.*)</tr>|iU", $block, $matches);
        // get the rows
        $lc = count($matches[0]);
        for ($i = 0; $i < $lc; ++$i) {
            if (@preg_match('|<td.*?>(.*?)</td><td.*?>(.*?)</td>|ms', $matches[1][$i], $match)) {
                @preg_match('/(\\d{1,2}|)\\s*(\\S+|)\\s*(\\d{4}|)/i', $match[2], $dat);
                $datum = array("day" => $dat[1], "month" => trim($dat[2]), "mon" => $this->monthNo(trim($dat[2])), "year" => trim($dat[3]), "full" => $dat[0]);
                if (strlen($dat[0])) {
                    $match[2] = trim(substr($match[2], strlen($dat[0]) + 1));
                }
                @preg_match('|<a name="author">(.*?)</a>|ims', $match[2], $author);
                if (!empty($author) && strlen($author[0])) {
                    $match[2] = trim(str_replace(', by: ' . $author[0], '', $match[2]));
                }
                if (!empty($author)) {
                    $resauthor = $author[1];
                } else {
                    $resauthor = '';
                }
                $res[] = array("inturl" => '', "name" => $match[1], "date" => $datum, "details" => trim($match[2]), "auturl" => '', "author" => $resauthor);
            }
        }
    }