Imdb\Title::writing PHP Method

writing() public method

Get the writer(s)
See also: IMDB page /fullcredits
public writing ( ) : array
return array writers (array[0..n] of arrays[imdb,name,role])
    public function writing()
    {
        if (empty($this->credits_writing)) {
            $page = $this->getPage("Credits");
            if (empty($page)) {
                return array();
                // no such page
            }
        }
        $writing_rows = $this->get_table_rows($this->page["Credits"], "Writing Credits");
        if (!$writing_rows) {
            $writing_rows = $this->get_table_rows($this->page["Credits"], "Series Writing Credits");
        }
        if (!$writing_rows) {
            return array();
        }
        for ($i = 0; $i < count($writing_rows); $i++) {
            $wrt = array();
            if (preg_match('!<a\\s+href="/name/nm(\\d{7})/[^>]*>\\s*(.+)\\s*</a>!ims', $writing_rows[$i], $match)) {
                $wrt['imdb'] = $match[1];
                $wrt['name'] = trim($match[2]);
            } elseif (preg_match('!<td\\s+class="name">(.+?)</td!ims', $writing_rows[$i], $match)) {
                $wrt['imdb'] = '';
                $wrt['name'] = trim($match[1]);
            } else {
                continue;
            }
            if (preg_match('!<td\\s+class="credit"\\s*>\\s*(.+?)\\s*</td>!ims', $writing_rows[$i], $match)) {
                $wrt['role'] = trim($match[1]);
            } else {
                $wrt['role'] = NULL;
            }
            $this->credits_writing[] = $wrt;
        }
        return $this->credits_writing;
    }