如何分组阵列听到?

时间:2014-10-30 06:31:30

标签: php arrays grouping

在我使用三个函数显示数据之前,我现在只编写了对所有数据的查询并将其作为数组分组。因为我想使用一个大数组显示所有数据... 我有这样的数组:

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

从那以后,我得到了这样的输出:

                 Array
                 (
[DON\'T MISS] => Array
    (
        [0] => Ram Charan\'s GAV movie: Live updates from movie hall
        [1] => breaking news article 1
        [2] => This is dont mis articles 1 
    )

[WEB EXCLUSIVE] => Array
    (
        [0] => This is the web exclusive article 1 .....
    )

[NON STOP] => Array
    (
        [0] => This is the non stop article 2 ...
    )

 )

我想把它作为一个:

  Array
 (
[0]=>Array{

   [DON\'T MISS] => Array
    (
        [0] => Ram Charan\'s GAV movie: Live updates from movie hall
        [1] => breaking news article 1
        [2] => This is dont mis articles 1 
    )
)
[1]=>Array(
      [WEB EXCLUSIVE] => Array
    (
        [0] => This is the web exclusive article 1 .....
    )
 )
[2]=>Array(
[NON STOP] => Array
    (
        [0] => This is the non stop article 2 ...
    )
)
  )

因为我想以这种方式为整个阵列制作foreach ... 请帮助我...

$ this-> getArticlesByLabels out put is ..我只给出那个数组格式我不能发布总数组因为那是非常大的....

   Array
   (
 [0] => Array
    (
        [ID] => 108347
        [Category_id] => 11204
        [title] => Ram Charan\'s GAV movie: Live updates from movie hall
    )
 [1] => Array
    (
        [ID] => 108346
        [Category_id] => 10
        [title] => breaking news article 1
        [text_data] => aafasfasdfasdfasdfasdf
    )
 [2]
  .
  .
[20]
   )

0 个答案:

没有答案