как классифицировать или группировать массив по дате

У меня есть список истории, который сгруппирован по дате DESC следующим образом:

----------- 28/Feb/2014 ----------- 27/Feb/2014 ----------- 27/Feb/2014 ----------- 27/Feb/2014 ------------ 26/Feb/2014 ------------ 26/Feb/2014 

Я хочу напечатать так.

 ----------- 28/Feb/2014 ----------- 27/Feb/2014 27/Feb/2014 27/Feb/2014 ------------ 26/Feb/2014 26/Feb/2014 

вот мой массив:

 array( (int) 0 => array( 'BriefHistory' => array( 'id' => '2', 'created' => '2014-02-28 14:51:08', 'created_by' => '7827', 'order_id' => 'OBE10003', 'brief_instalment_id' => '2', 'brief_history_type_id' => '1' ) ), (int) 1 => array( 'BriefHistory' => array( 'id' => '4', 'created' => '2014-02-27 16:18:40', 'created_by' => '7827', 'order_id' => 'OBE10003', 'brief_instalment_id' => '2', 'brief_history_type_id' => '4' ) ), (int) 2 => array( 'BriefHistory' => array( 'id' => '1', 'created' => '2014-02-27 14:51:08', 'created_by' => '7827', 'order_id' => 'OBE10003', 'brief_instalment_id' => '1', 'brief_history_type_id' => '1' ) ), (int) 3 => array( 'BriefHistory' => array( 'id' => '3', 'created' => '2014-02-26 16:18:09', 'created_by' => '7827', 'order_id' => 'OBE10003', 'brief_instalment_id' => '1', 'brief_history_type_id' => '3' ) ) ) 

PHP:

 <?php foreach ($briefHistories as $briefHistorie) { ?> <div class="brief-summary-row"> <div> <?php echo TimeUtil::format( "d/M/Y", $briefHistorie['BriefHistory']['created']); ?> </div> </div> <?php } ?> 

 <?php $current = TimeUtil::format( "d/M/Y", $briefHistories[0]['BriefHistory']['created']); echo '<div class="brief-summary-row"><div>'; foreach ($briefHistories as $briefHistorie) { $created = TimeUtil::format( "d/M/Y", $briefHistorie['BriefHistory'['created']); echo $created; if($created != $current){ echo '</div></div><div class="brief-summary-row"><div>'; $current = $created; } } echo '</div></div>'; ?> 

Что-то в этом роде. Может быть уплотнен:

 $previous = ''; foreach ($briefHistories as $briefHistorie) { $date = TimeUtil::format("d/M/Y", $briefHistorie['BriefHistory']['created']); if($date != $previous) { echo '<div class="brief-summary-row">'; } echo '<div>'.$date.'</div>'; if($date != $previous) { echo '</div>'; } $previous = $date; } 

для других

  $arrayDates = array(); $i = 0; $key = array(); foreach ($briefHistories as $briefHistorie) { $key_name = date('Ymd', strtotime($briefHistorie['BriefHistory']['created'])); if(!isset($key[$key_name])){ $key[$key_name]=$i; $i++; } $arrayDates[$key[$key_name]][]= $briefHistorie; } foreach ($arrayDates as $arrayDate ) { echo '<div class="brief-summary-row">'; foreach ($arrayDate as $data) { echo '<strong>'.date('dm-Y', strtotime($data['BriefHistory']['created'])).'</strong>'; } echo '</div>'; } 

распечатать =>

 <div class="brief-summary-row"> <strong>28-02-2014</strong> </div> <div class="brief-summary-row"> <strong>27-02-2014</strong> <strong>27-02-2014</strong> <strong>27-02-2014</strong> <strong>27-02-2014</strong> </div> <div class="brief-summary-row"> <strong>26-02-2014</strong> <strong>26-02-2014</strong> </div> <div class="brief-summary-row"> <strong>25-02-2014</strong> </div> 

для других Здесь представлена ​​демонстрация массива