並べ替えたい日付の配列またはオブジェクトがあります。
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
ありがとう