Может кто-нибудь помочь мне, мне нужно отсортировать этот массив:
$report_fields['client_id'] = $row['client_id'];
$report_fields['name'] = $row['name'];
$report_fields['is_authorized'] = $row['is_authorized'];
$report_fields['date_created'] = $row['date_created'];
$report_fields['service_id'] = $row['service_id'];
$report_fields['type_id'] = $row['type_id'];
$report_fields['report_name'] = $report_types[$row['type_id']]['type'];
$report_groups[$row['ref_no']][$row['id']] = $report_fields;
Я пробовал usort следующим образом:
usort($report_groups[$row['ref_no']],'cmp');
function cmp($a,$b) {
$a_stm = strtotime($a["date_created"]);
$b_stm = strtotime($b["date_created"]);
if ($a_stm == $b_stm) {
return 0;
}
return ($a_stm < $b_stm) ? -1 : 1;
}
Но возвращаемый результат неверен.