我不知道如何把這個。我有這個功能:作爲變量的快速功能
protected function _do_thumb($temaid)
{
$firstPost = $this->registry->topics->getPostById($temaid);
preg_match('/< *img[^>]*src *= *["\']?([^"\']*)/i', $firstPost['post'], $match);
return $match[1];
}
[...]
while ($i = $this->DB->fetch())
{
$forum = $this->registry->class_forums->forum_by_id[ $i['forum_id'] ];
if ($this->registry->permissions->check('read', $forum) != TRUE)
{
continue;
}
if ($forum['password'] != "")
{
continue;
}
$to_echo .= $this->_parseTemplate($row, array (
'topic_title' => str_replace('&#', '&#', $i['title']),
'topic_id' => $i['tid'],
'topic_link' => "showtopic=".$i['tid'],
'forum_title' => htmlspecialchars($forum['name']),
'forum_id' => $i['forum_id'],
'last_poster_id' => $i['last_poster_id'],
'last_post_name' => $i['last_poster_name'],
'last_post_time' => $this->registry->getClass('class_localization')->getDate($i['last_post'] , 'LONG', 1),
'timestamp' => $i['start_date'],
'starter_id' => $i['starter_id'],
'starter_name' => $i['starter_name'],
'board_url' => $this->settings['board_url'],
'board_name' => $this->settings['board_name'],
'rfc_date' => date('j\-M\-Y', $i['start_date']),
'thumb' => $this->_do_thumb($i['topic_firstpost'])
)) . "\r\n";
}
$ firstPost應該產生另一個函數的值結果。這裏的問題是該函數似乎在整個循環的一半停止,所以它返回一個不完整的結果,而只返回一個列表的第一個元素。 $ forum但是工作正常,因爲它被表示爲一個變量,所以我相信解決方案可能是以相同的方式表達$ topic。就像這樣:
$this->registry->topics->getPostById[ $temaid ];
但是,我不知道我該怎麼做。它甚至有可能嗎?
謝謝。
您確定這是故意的嗎? '$ fetch_sql()' –
是的,我刪節了這個函數,因爲它比這更復雜。但簡單地說,它。 –
你能添加完整的代碼嗎? '$ some_stuff。= array('forum_title'=> $ forum ['name'],'thumb'=> $ topic ['firstpost']);'無效 –