2014-10-29 41 views
0

我有兩個表,如標籤和內容。我寫了兩個表的內部聯接。如何在此組合數組?

我已經wirtten這樣的代碼..

$menu_array=array(); 
foreach($this->getArticlesByLabels as $k){ 
    $menu_array[$k['label_name']][]=$k; 
} 

它showiing

Array 
(
    [DON'T MISS] => Array 
    (
     [0] => Array 
     (
     [ID] => 108347 
     [Category_id] => 11204 
     [title] => Ram Charan\'s GAV movie: Live updates from movie hall 
     [text_data] => afadsfas   
    ) 

在這裏它的顯示數據與標籤name.I意味着它是通過標籤名稱分組,但我想顯示的數據動態如何使用循環顯示數據..

回答

0

試試這個:

foreach($this->getArticlesByLabels as $k){ 
    echo $k['ID']; 
    echo $k['Category_id']; 
    echo $k['title']; 
    echo $k['text_data']; 
} 
+0

沒有不喜歡的,我想首先顯示的標籤名稱後,我不得不顯示標籤相關的數據,我必須顯示3個標籤 – 2014-10-29 11:30:16

0

可能:

$menu_array=array(); 
foreach($this->getArticlesByLabels as $k){ 
    $menu_array['label_name']= $k['label_name']; 
} 

或:

foreach($this->getArticlesByLabels as $k){ 
    $menu_array=array($k); 
} 

或標籤名稱:

foreach($this->getArticlesByLabels as $k){ 
    $menu_array=array($k['label_name']); 
}