문제

I have the following code which gets all news:

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;
    }

In the same class I have a bbedit() function. I want to get the value of $news[int]['news_content'] and pass it to that function bbedit().

도움이 되었습니까?

해결책

Use $this to call a function within class:

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

or

while($row = mysql_fetch_array($query)){
    $news[] = $this->bbedit($row['news_content']);
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top