2011-09-28 87 views
0

鉴于此阵:PHP集团通过

array(1) { 
    [0]=> 
    array(2) { 
    ["Project"]=> 
    array(5) { 
     ["id"]=> 
     string(1) "2" 
     ["user_id"]=> 
     string(2) "21" 
     ["customer_id"]=> 
     string(1) "4" 
     ["name"]=> 
     string(15) "WordPress Theme" 
     ["created"]=> 
     string(19) "2011-09-26 21:30:38" 
    } 
    ["Track"]=> 
    array(1) { 
     [0]=> 
     array(8) { 
     ["id"]=> 
     string(1) "7" 
     ["user_id"]=> 
     string(2) "21" 
     ["project"]=> 
     string(1) "2" 
     ["customer"]=> 
     string(1) "4" 
     ["title"]=> 
     string(7) "Backend" 
     ["notes"]=> 
     string(0) "" 
     ["created"]=> 
     string(19) "2011-09-28 22:21:22" 
     ["Lapse"]=> 
     array(2) { 
      [0]=> 
      array(5) { 
      ["id"]=> 
      string(1) "4" 
      ["track_id"]=> 
      string(1) "7" 
      ["start"]=> 
      string(19) "2011-09-28 22:22:21" 
      ["stop"]=> 
      string(19) "2011-09-28 22:22:30" 
      ["created"]=> 
      string(19) "2011-09-28 22:22:21" 
      } 
      [1]=> 
      array(5) { 
      ["id"]=> 
      string(1) "3" 
      ["track_id"]=> 
      string(1) "7" 
      ["start"]=> 
      string(19) "2011-09-28 22:22:07" 
      ["stop"]=> 
      string(19) "2011-09-28 22:22:12" 
      ["created"]=> 
      string(19) "2011-09-28 22:22:07" 
      } 
     } 
     } 
    } 
    } 
} 

我将如何通过组中的一天流逝阵列与PHP?这可能更容易直接使用MySQL,但我使用CakePHP的递归函数,我无法弄清楚如何使用Group By!

+1

“这可能更容易直接使用MySQL,但我使用CakePHP的递归函数,我无法弄清楚如何使用Group By!” ---你不能用php做到这一点;-P – zerkms

+0

我担心。回到绘图板... – benhowdle89

+0

我刚刚在CakePHP + GROUP +关联上回答了[一个问题](http://stackoverflow.com/questions/7590402/cakephp-combining-recursive-and-group),你应该带一个看。 *编辑*刚注意到另一个问题也是你的! :) – bfavaretto

回答

0
$list = array(); 

function extractByDates($arr) { 
    foreach ($arr as $key => $v) 
    if (is_array($v)) 
     function extractByDates($v); 
    else if ($key == 'created') 
     $list[$v] = $v; 
} 

extractByDates($yourGivenArray); 

我没有测试!