-1

我有以下代码可以获取所有新闻:

private function get_news()
    {   
        $news = array();

        $query  = $this->database->query("SELECT * FROM `news` ORDER BY `news_id` DESC");
        while($row = mysql_fetch_array($query))
        {
            $news[] = $row;
        }

        return $news;
    }

在同一个班级我有一个bbedit()功能。我想获取$news[ int ]的值['news_content']并将其传递给该函数bbedit()

4

1 回答 1

2

用于$this调用类中的函数:

private function bbedit(){
    $news = $this->get_news(); // news will have all your array
    foreach($news as $key => $val){
        // do something with $val['news_content'];
    }
}

或者

while($row = mysql_fetch_array($query)){
    $news[] = $this->bbedit($row['news_content']);
}
于 2012-10-05T07:09:12.147 回答