我有一個數組或具有日期的對象,我希望按其排序。PHP按月排列數組,然後是年份
我有我傳遞給usort
function sortMonths($a, $b) {
if ($a->received_date == $b->received_date) return 0;
return ($a->received_date > $b->received_date) ? 1 : -1;
}
做哪些要求和日期排序以下自定義函數,所以我得到:
2009-05-01 2009-03-01 2008 -05-01 2008-03-01 2007-03-01
但是我怎麼組合在一起的幾個月,然後才能在今年獲得:
2009-05-01 2008-05-01 2009-03-01 2008-03-01 2007-03-01
感謝
非常感謝你。真棒:) – rookang 2009-10-28 12:05:18