我想按日期和時間按ISO 8601格式對PHP中的數組進行排序。我仍然試圖掌握PHP,並嘗試了很多堆棧溢出的解決方案,但我無法確定正確的功能。希望這是一個簡單的答案,對別人會有幫助。按ISO排序PHP數組日期
僅供參考,此陣列由Citrix API for GoToMeeting生成。我想首先在列表中以最快的時間基於startTime對數組進行排序。
這裏是陣列的樣子使用帶有兩個結果var_export介紹:
array (
0 => stdClass::__set_state(
array(
'createTime' => '2012-07-03T19:36:58.+0000',
'status' => 'INACTIVE',
'subject' => 'Client 1',
'startTime' => '2012-07-10T14:00:00.+0000',
'conferenceCallInfo' => 'United States: xxxxx Access Code: xxxxx',
'passwordRequired' => 'false',
'meetingType' => 'Scheduled',
'maxParticipants' => 26,
'endTime' => '2012-07-10T15:00:00.+0000',
'uniqueMeetingId' => 12345678,
'meetingid' => 123456789,
)
),
1 => stdClass::__set_state(
array(
'createTime' => '2012-07-02T21:57:48.+0000',
'status' => 'INACTIVE',
'subject' => 'Client 2',
'startTime' => '2012-07-06T19:00:00.+0000',
'conferenceCallInfo' => 'United States: xxxxx Access Code: xxxxx',
'passwordRequired' => 'false',
'meetingType' => 'Scheduled',
'maxParticipants' => 26,
'endTime' => '2012-07-06T20:00:00.+0000',
'uniqueMeetingId' => 12345678,
'meetingid' => 123456789,
)
),
)
我的目標是,將其輸出數組使用foreach循環HTML div的,這個代碼已經完成,效果很好,但我排序關閉:-)
預先感謝您的幫助!
史蒂夫
關於ISO8601的好處是,你可以一般只是做一個簡單的字符串排序,並讓他們在正確的順序。看看[usort()](http://php.net/usort) –