PHP 多维数组排序让我有点困惑。
我所拥有的是json_decode()
从.jsonp
文件中形成的数组。
它在每个主数组条目中有几个变量。它们包括“Year”、“Month”、“Day”、“hourTimeStart”和“minuteTimeStart”,以及其他一些信息。
我想按日期对这个数组进行排序,所以我想先按“minuteTimeStart”、“hourTimeStart”、“Day”排序,然后是“Month”,然后是“Year”,所以它们是按时间顺序排列的。
数组如下所示:
Array (
[0] => Array ( [Year] => 2013 [Month] => February [Day] => 5 [hourTimeStart] => 5 [minuteTimeStart] => 0 [Name] => tht )
[1] => Array ( [Year] => 2013 [Month] => January [Day] => 6 [hourTimeStart] => 2 [minuteTimeStart] => 0 [Name] => gregre)
[2] => Array ( [Year] => 2013 [Month] => March [Day] => 4 [hourTimeStart] => 1 [minuteTimeStart] => 15 [Name] => gregre)
)
基本上我正在做的是:
$databaseFileURL = "../Appointments/AllAppointmentData.jsonp";
if(file_exists($databaseFileURL)){
$jsonAppointmentData = file_get_contents($databaseFileURL);
} else $jsonAppointmentData = "";
$AppointmentData = json_decode($jsonAppointmentData, true);
然后我想$AppointmentData
按每个子数组中指示的日期排序