2016-10-18 45 views
0

我只是尋找一些建議,我將如何制定出最好的會議時段。所以學生會議不會重疊,也不會太遠。我正在嘗試推薦推薦的時間,以便父母可以看到最好的預訂時段,以便他們不會等待。確定哪個時間最適合推入數組的最佳方法?

E.g它應該如何工作:

家長1:

Child 1 and Child 2 

會議1:

Slot `2016-10-07 14:00:00` (free)(duration 10mins)(Child 1) 
Slot `2016-10-07 14:10:00` (free)(duration 10mins)(Child 2) 
Slot `2016-10-07 14:20:00` (free)(duration 10mins) 

會議2:

Slot `2016-10-07 14:15:00` (free)(duration 5mins) 
Slot `2016-10-07 14:20:00` (free)(duration 5mins)(Child 1) 
Slot `2016-10-07 14:25:00` (free)(duration 5mins)(Child 2) 

會議3:

Slot `2016-10-07 14:10:00` (free)(duration 10mins) 
Slot `2016-10-07 14:20:00` (free)(duration 10mins) 
Slot `2016-10-07 14:30:00` (free)(duration 10mins)(Child 1) 
Slot `2016-10-07 14:40:00` (free)(duration 10mins)(Child 2) 

什麼是最好的方法來檢查時間還沒有被存儲到一個數組中,如果時間已經存儲,然後檢查下次是否可以適應其他時間基於持續時間?

你不必使用我的數據,一個例子將是有用的。提前致謝。

數據我已經走到這一步:

學生:

Array 
(
    [0] => pupil Object (
      [id] => 48307 
      [school_id] => 1 
      [grade_id] => 87 
      [firstname] => Callum 
      [surname] => Lacey 
      [gender] => M 
      [username] => callum 
      [password] => callum 
      [avatar] => 003_large.gif 
      [uuid] => 
      [active] => 1 
      [deleted] => 0 
      [inserted] => 2015-09-14 10:57:29 
      [updated] => 2016-09-15 13:09:07 
      [login] => 2016-09-26 15:07:15 
     ) 

    [1] => pupil Object (
      [id] => 79571 
      [school_id] => 1 
      [grade_id] => 87 
      [firstname] => Daniel 
      [surname] => Lacey 
      [gender] => M 
      [username] => daniellacey 
      [password] => password123 
      [avatar] => 003_large.gif 
      [uuid] => 
      [active] => 1 
      [deleted] => 0 
      [inserted] => 2016-07-06 10:51:26 
      [updated] => 2016-09-15 12:23:53 
      [login] => 2016-09-23 13:09:28 
     ) 
) 

加載哪些是免費的所有會議插槽:

Array 
(
    [0] => meeting Object ( 
      [errors] => 0 
      [id] => 1812 
      [title] => Parent Evening 1 - 2016-10-07 14:00 
      [slot_id] => 31305 
      [grade_id] => 87 
      [startTime] => 2016-10-07 14:00:00 
      [endTime] => 2016-10-07 14:10:00 
     ) 

    [1] => meeting Object (
      [errors] => 0 
      [id] => 1815 
      [title] => Parent Evening 3 - 2016-10-07 14:00 
      [slot_id] => 31317 
      [grade_id] => 87 
      [startTime] => 2016-10-07 14:30:00 
      [endTime] => 2016-10-07 14:40:00 
     ) 
    [2] => meeting Object (
      [errors] => 0 
      [id] => 1815 
      [title] => Parent Evening 3 - 2016-10-07 14:00 
      [slot_id] => 31318 
      [grade_id] => 87 
      [startTime] => 2016-10-07 14:40:00 
      [endTime] => 2016-10-07 14:50:00 
     ) 
    [3] => meeting Object (
      [errors] => 0 
      [id] => 1815 
      [title] => Parent Evening 3 - 2016-10-07 14:00 
      [slot_id] => 31319 
      [grade_id] => 87 
      [startTime] => 2016-10-07 14:50:00 
      [endTime] => 2016-10-07 15:00:00 
     ) 
    [4] => meeting Object (
      [errors] => 0 
      [id] => 1816 
      [title] => 2016-10-07 14:15 
      [slot_id] => 31321 
      [grade_id] => 87 
      [startTime] => 2016-10-07 14:15:00 
      [endTime] => 2016-10-07 14:20:00 
     ) 
    [5] => meeting Object (
      [errors] => 0 
      [id] => 1815 
      [title] => Parent Evening 3 - 2016-10-07 14:00 
      [slot_id] => 31320 
      [grade_id] => 87 
      [startTime] => 2016-10-07 15:00:00 
      [endTime] => 2016-10-07 15:10:00 
     ) 
    [6] => meeting Object (
      [errors] => 0 
      [id] => 1813 
      [title] => Parent Evening 2 - 2016-10-07 14:00 
      [slot_id] => 31312 
      [grade_id] => 87 
      [startTime] => 2016-10-07 14:40:00 
      [endTime] => 2016-10-07 14:50:00 
     ) 
    [7] => meeting Object (
      [errors] => 0 
      [id] => 1813 
      [title] => Parent Evening 2 - 2016-10-07 14:00 
      [slot_id] => 31311 
      [grade_id] => 87 
      [startTime] => 2016-10-07 14:30:00 
      [endTime] => 2016-10-07 14:40:00 
     ) 
    [8] => meeting Object (
      [errors] => 0 
      [id] => 1812 
      [title] => Parent Evening 1 - 2016-10-07 14:00 
      [slot_id] => 31306 
      [grade_id] => 87 
      [startTime] => 2016-10-07 14:10:00 
      [endTime] => 2016-10-07 14:20:00 
     ) 
    [9] => meeting Object (
      [errors] => 0 
      [id] => 1812 
      [title] => Parent Evening 1 - 2016-10-07 14:00 
      [slot_id] => 31307 
      [grade_id] => 87 
      [startTime] => 2016-10-07 14:20:00 
      [endTime] => 2016-10-07 14:30:00 
     ) 
    [10] => meeting Object (
      [errors] => 0 
      [id] => 1812 
      [title] => Parent Evening 1 - 2016-10-07 14:00 
      [slot_id] => 31308 
      [grade_id] => 87 
      [startTime] => 2016-10-07 14:30:00 
      [endTime] => 2016-10-07 14:40:00 
     ) 
    [11] => meeting Object (
      [errors] => 0 
      [id] => 1813 
      [title] => Parent Evening 2 - 2016-10-07 14:00 
      [slot_id] => 31310 
      [grade_id] => 87 
      [startTime] => 2016-10-07 14:20:00 
      [endTime] => 2016-10-07 14:30:00 
     ) 
    [12] => meeting Object (
      [errors] => 0 
      [id] => 1813 
      [title] => Parent Evening 2 - 2016-10-07 14:00 
      [slot_id] => 31309 
      [grade_id] => 87 
      [startTime] => 2016-10-07 14:10:00 
      [endTime] => 2016-10-07 14:20:00 
     ) 
    [13] => meeting Object (
      [errors] => 0 
      [id] => 1816 
      [title] => 2016-10-07 14:15 
      [slot_id] => 31322 
      [grade_id] => 87 
      [startTime] => 2016-10-07 14:20:00 
      [endTime] => 2016-10-07 14:25:00 
     ) 
    [14] => meeting Object (
      [errors] => 0 
      [id] => 1816 
      [title] => 2016-10-07 14:15 
      [slot_id] => 31323 
      [grade_id] => 87 
      [startTime] => 2016-10-07 14:25:00 
      [endTime] => 2016-10-07 14:30:00 
     ) 
    [15] => meeting Object (
      [errors] => 0 
      [id] => 1819 
      [title] => 2016-10-07 14:20 
      [slot_id] => 31341 
      [grade_id] => -1 
      [startTime] => 2016-10-07 15:10:00 
      [endTime] => 2016-10-07 15:20:00 
     ) 
    [16] => meeting Object (
      [errors] => 0 
      [id] => 1819 
      [title] => 2016-10-07 14:20 
      [slot_id] => 31342 
      [grade_id] => -1 
      [startTime] => 2016-10-07 15:20:00 
      [endTime] => 2016-10-07 15:30:00 
     ) 
    [17] => meeting Object (
      [errors] => 0 
      [id] => 1819 
      [title] => 2016-10-07 14:20 
      [slot_id] => 31343 
      [grade_id] => -1 
      [startTime] => 2016-10-07 15:30:00 
      [endTime] => 2016-10-07 15:40:00 
     ) 
    [18] => meeting Object (
      [errors] => 0 
      [id] => 1819 
      [title] => 2016-10-07 14:20 
      [slot_id] => 31345 
      [grade_id] => -1 
      [startTime] => 2016-10-07 15:50:00 
      [endTime] => 2016-10-07 16:00:00 
     ) 
    [19] => meeting Object (
      [errors] => 0 
      [id] => 1819 
      [title] => 2016-10-07 14:20 
      [slot_id] => 31344 
      [grade_id] => -1 
      [startTime] => 2016-10-07 15:40:00 
      [endTime] => 2016-10-07 15:50:00 
     ) 
    [20] => meeting Object (
      [errors] => 0 
      [id] => 1819 
      [title] => 2016-10-07 14:20 
      [slot_id] => 31340 
      [grade_id] => -1 
      [startTime] => 2016-10-07 15:00:00 
      [endTime] => 2016-10-07 15:10:00 
     ) 
    [21] => meeting Object (
      [errors] => 0 
      [id] => 1819 
      [title] => 2016-10-07 14:20 
      [slot_id] => 31339 
      [grade_id] => -1 
      [startTime] => 2016-10-07 14:50:00 
      [endTime] => 2016-10-07 15:00:00 
     ) 
    [22] => meeting Object (
      [errors] => 0 
      [id] => 1816 
      [title] => 2016-10-07 14:15 
      [slot_id] => 31324 
      [grade_id] => 87 
      [startTime] => 2016-10-07 14:30:00 
      [endTime] => 2016-10-07 14:35:00 
     ) 
    [23] => meeting Object (
      [errors] => 0 
      [id] => 1816 
      [title] => 2016-10-07 14:15 
      [slot_id] => 31325 
      [grade_id] => 87 
      [startTime] => 2016-10-07 14:35:00 
      [endTime] => 2016-10-07 14:40:00 
     ) 
    [24] => meeting Object (
      [errors] => 0 
      [id] => 1819 
      [title] => 2016-10-07 14:20 
      [slot_id] => 31336 
      [grade_id] => -1 
      [startTime] => 2016-10-07 14:20:00 
      [endTime] => 2016-10-07 14:30:00 
     ) 
    [25] => meeting Object (
      [errors] => 0 
      [id] => 1819 
      [title] => 2016-10-07 14:20 
      [slot_id] => 31338 
      [grade_id] => -1 
      [startTime] => 2016-10-07 14:40:00 
      [endTime] => 2016-10-07 14:50:00 
     ) 
    [26] => meeting Object (
      [errors] => 0 
      [id] => 1819 
      [title] => 2016-10-07 14:20 
      [slot_id] => 31337 
      [grade_id] => -1 
      [startTime] => 2016-10-07 14:30:00 
      [endTime] => 2016-10-07 14:40:00 
     ) 
) 

使用學生和加載會議插槽,推時隙爲每個學生和會議開會:

Array 
(
    [2016-10-07 14:00:00] => Array (
      [0] => meeting Object (
        [errors] => 0 
        [pupil_id] => 48307 
        [fullname] => Callum Lacey 
        [school_id] => 1 
        [meeting_title] => Parent Evening 1 
        [meeting_id] => 1812 
        [slot_id] => 87 
        [startTime] => 2016-10-07 14:00:00 
        [endTime] => 2016-10-07 14:10:00 
        [duration] => 600 
       ) 
      [1] => meeting Object (
        [errors] => 0 
        [pupil_id] => 79571 
        [fullname] => Daniel Lacey 
        [school_id] => 1 
        [meeting_title] => Parent Evening 1 
        [meeting_id] => 1812 
        [slot_id] => 87 
        [startTime] => 2016-10-07 14:10:00 
        [endTime] => 2016-10-07 14:20:00 
        [duration] => 600 
       ) 
      [2] => meeting Object (
        [errors] => 0 
        [pupil_id] => 48307 
        [fullname] => Callum Lacey 
        [school_id] => 1 
        [meeting_title] => 2016-10-07 14:15 
        [meeting_id] => 1816 
        [slot_id] => 87 
        [startTime] => 2016-10-07 14:15:00 
        [endTime] => 2016-10-07 14:20:00 
        [duration] => 300 
       ) 
      [3] => meeting Object (
        [errors] => 0 
        [pupil_id] => 79571 
        [fullname] => Daniel Lacey 
        [school_id] => 1 
        [meeting_title] => Parent Evening 2 
        [meeting_id] => 1813 
        [slot_id] => 87 
        [startTime] => 2016-10-07 14:20:00 
        [endTime] => 2016-10-07 14:30:00 
        [duration] => 600 
       ) 
      [4] => meeting Object (
        [errors] => 0 
        [pupil_id] => 79571 
        [fullname] => Daniel Lacey 
        [school_id] => 1 
        [meeting_title] => 2016-10-07 14:15 
        [meeting_id] => 1816 
        [slot_id] => 87 
        [startTime] => 2016-10-07 14:25:00 
        [endTime] => 2016-10-07 14:30:00 
        [duration] => 300 
       ) 
      [5] => meeting Object (
        [errors] => 0 
        [pupil_id] => 48307 
        [fullname] => Callum Lacey 
        [school_id] => 1 
        [meeting_title] => Parent Evening 3 
        [meeting_id] => 1815 
        [slot_id] => 87 
        [startTime] => 2016-10-07 14:30:00 
        [endTime] => 2016-10-07 14:40:00 
        [duration] => 600 
       ) 
      [6] => meeting Object (
        [errors] => 0 
        [pupil_id] => 48307 
        [fullname] => Callum Lacey 
        [school_id] => 1 
        [meeting_title] => Parent Evening 2 
        [meeting_id] => 1813 
        [slot_id] => 87 
        [startTime] => 2016-10-07 14:40:00 
        [endTime] => 2016-10-07 14:50:00 
        [duration] => 600 
       ) 
      [7] => meeting Object (
        [errors] => 0 
        [pupil_id] => 79571 
        [fullname] => Daniel Lacey 
        [school_id] => 1 
        [meeting_title] => Parent Evening 3 
        [meeting_id] => 1815 
        [slot_id] => 87 
        [startTime] => 2016-10-07 14:50:00 
        [endTime] => 2016-10-07 15:00:00 
        [duration] => 600 
       ) 
     ) 

    [2016-10-07 14:10:00] => Array (
      [0] => meeting Object (
        [errors] => 0 
        [pupil_id] => 79571 
        [fullname] => Daniel Lacey 
        [school_id] => 1 
        [meeting_title] => Parent Evening 1 
        [meeting_id] => 1812 
        [slot_id] => 87 
        [startTime] => 2016-10-07 14:00:00 
        [endTime] => 2016-10-07 14:10:00 
        [duration] => 600 
       ) 

      [1] => meeting Object (
        [errors] => 0 
        [pupil_id] => 48307 
        [fullname] => Callum Lacey 
        [school_id] => 1 
        [meeting_title] => Parent Evening 1 
        [meeting_id] => 1812 
        [slot_id] => 87 
        [startTime] => 2016-10-07 14:10:00 
        [endTime] => 2016-10-07 14:20:00 
        [duration] => 600 
       ) 
      [2] => meeting Object ( 
        [errors] => 0 
        [pupil_id] => 48307 
        [fullname] => Callum Lacey 
        [school_id] => 1 
        [meeting_title] => 2016-10-07 14:15 
        [meeting_id] => 1816 
        [slot_id] => 87 
        [startTime] => 2016-10-07 14:15:00 
        [endTime] => 2016-10-07 14:20:00 
        [duration] => 300 
       ) 
      [3] => meeting Object (
        [errors] => 0 
        [pupil_id] => 79571 
        [fullname] => Daniel Lacey 
        [school_id] => 1 
        [meeting_title] => Parent Evening 2 
        [meeting_id] => 1813 
        [slot_id] => 87 
        [startTime] => 2016-10-07 14:20:00 
        [endTime] => 2016-10-07 14:30:00 
        [duration] => 600 
       ) 
      [4] => meeting Object (
        [errors] => 0 
        [pupil_id] => 79571 
        [fullname] => Daniel Lacey 
        [school_id] => 1 
        [meeting_title] => 2016-10-07 14:15 
        [meeting_id] => 1816 
        [slot_id] => 87 
        [startTime] => 2016-10-07 14:25:00 
        [endTime] => 2016-10-07 14:30:00 
        [duration] => 300 
       ) 
      [5] => meeting Object (
        [errors] => 0 
        [pupil_id] => 48307 
        [fullname] => Callum Lacey 
        [school_id] => 1 
        [meeting_title] => Parent Evening 3 
        [meeting_id] => 1815 
        [slot_id] => 87 
        [startTime] => 2016-10-07 14:30:00 
        [endTime] => 2016-10-07 14:40:00 
        [duration] => 600 
       ) 
      [6] => meeting Object (
        [errors] => 0 
        [pupil_id] => 48307 
        [fullname] => Callum Lacey 
        [school_id] => 1 
        [meeting_title] => Parent Evening 2 
        [meeting_id] => 1813 
        [slot_id] => 87 
        [startTime] => 2016-10-07 14:40:00 
        [endTime] => 2016-10-07 14:50:00 
        [duration] => 600 
       ) 
      [7] => meeting Object (
        [errors] => 0 
        [pupil_id] => 79571 
        [fullname] => Daniel Lacey 
        [school_id] => 1 
        [meeting_title] => Parent Evening 3 
        [meeting_id] => 1815 
        [slot_id] => 87 
        [startTime] => 2016-10-07 14:50:00 
        [endTime] => 2016-10-07 15:00:00 
        [duration] => 600 
       ) 
     ) 

    [2016-10-07 14:20:00] => Array (
      [0] => meeting Object (
        [errors] => 0 
        [pupil_id] => 79571 
        [fullname] => Daniel Lacey 
        [school_id] => 1 
        [meeting_title] => Parent Evening 1 
        [meeting_id] => 1812 
        [slot_id] => 87 
        [startTime] => 2016-10-07 14:00:00 
        [endTime] => 2016-10-07 14:10:00 
        [duration] => 600 
       ) 
      [1] => meeting Object (
        [errors] => 0 
        [pupil_id] => 79571 
        [fullname] => Daniel Lacey 
        [school_id] => 1 
        [meeting_title] => Parent Evening 2 
        [meeting_id] => 1813 
        [slot_id] => 87 
        [startTime] => 2016-10-07 14:10:00 
        [endTime] => 2016-10-07 14:20:00 
        [duration] => 600 
       ) 
      [2] => meeting Object (
        [errors] => 0 
        [pupil_id] => 48307 
        [fullname] => Callum Lacey 
        [school_id] => 1 
        [meeting_title] => 2016-10-07 14:15 
        [meeting_id] => 1816 
        [slot_id] => 87 
        [startTime] => 2016-10-07 14:15:00 
        [endTime] => 2016-10-07 14:20:00 
        [duration] => 300 
       ) 
      [3] => meeting Object (
        [errors] => 0 
        [pupil_id] => 48307 
        [fullname] => Callum Lacey 
        [school_id] => 1 
        [meeting_title] => Parent Evening 1 
        [meeting_id] => 1812 
        [slot_id] => 87 
        [startTime] => 2016-10-07 14:20:00 
        [endTime] => 2016-10-07 14:30:00 
        [duration] => 600 
       ) 
      [4] => meeting Object ( 
        [errors] => 0 
        [pupil_id] => 79571 
        [fullname] => Daniel Lacey 
        [school_id] => 1 
        [meeting_title] => 2016-10-07 14:15 
        [meeting_id] => 1816 
        [slot_id] => 87 
        [startTime] => 2016-10-07 14:25:00 
        [endTime] => 2016-10-07 14:30:00 
        [duration] => 300 
       ) 
      [5] => meeting Object (
        [errors] => 0 
        [pupil_id] => 48307 
        [fullname] => Callum Lacey 
        [school_id] => 1 
        [meeting_title] => Parent Evening 3 
        [meeting_id] => 1815 
        [slot_id] => 87 
        [startTime] => 2016-10-07 14:30:00 
        [endTime] => 2016-10-07 14:40:00 
        [duration] => 600 
       ) 
      [6] => meeting Object (
        [errors] => 0 
        [pupil_id] => 48307 
        [fullname] => Callum Lacey 
        [school_id] => 1 
        [meeting_title] => Parent Evening 2 
        [meeting_id] => 1813 
        [slot_id] => 87 
        [startTime] => 2016-10-07 14:40:00 
        [endTime] => 2016-10-07 14:50:00 
        [duration] => 600 
       ) 
      [7] => meeting Object (
        [errors] => 0 
        [pupil_id] => 79571 
        [fullname] => Daniel Lacey 
        [school_id] => 1 
        [meeting_title] => Parent Evening 3 
        [meeting_id] => 1815 
        [slot_id] => 87 
        [startTime] => 2016-10-07 14:50:00 
        [endTime] => 2016-10-07 15:00:00 
        [duration] => 600 
       ) 
     ) 

    [2016-10-07 14:30:00] => Array (
      [0] => meeting Object (
        [errors] => 0 
        [pupil_id] => 79571 
        [fullname] => Daniel Lacey 
        [school_id] => 1 
        [meeting_title] => Parent Evening 1 
        [meeting_id] => 1812 
        [slot_id] => 87 
        [startTime] => 2016-10-07 14:00:00 
        [endTime] => 2016-10-07 14:10:00 
        [duration] => 600 
       ) 
      [1] => meeting Object (
        [errors] => 0 
        [pupil_id] => 79571 
        [fullname] => Daniel Lacey 
        [school_id] => 1 
        [meeting_title] => Parent Evening 2 
        [meeting_id] => 1813 
        [slot_id] => 87 
        [startTime] => 2016-10-07 14:10:00 
        [endTime] => 2016-10-07 14:20:00 
        [duration] => 600 
       ) 
      [2] => meeting Object (
        [errors] => 0 
        [pupil_id] => 48307 
        [fullname] => Callum Lacey 
        [school_id] => 1 
        [meeting_title] => 2016-10-07 14:15 
        [meeting_id] => 1816 
        [slot_id] => 87 
        [startTime] => 2016-10-07 14:15:00 
        [endTime] => 2016-10-07 14:20:00 
        [duration] => 300 
       ) 
      [3] => meeting Object (
        [errors] => 0 
        [pupil_id] => 48307 
        [fullname] => Callum Lacey 
        [school_id] => 1 
        [meeting_title] => Parent Evening 2 
        [meeting_id] => 1813 
        [slot_id] => 87 
        [startTime] => 2016-10-07 14:20:00 
        [endTime] => 2016-10-07 14:30:00 
        [duration] => 600 
       ) 
      [4] => meeting Object (
        [errors] => 0 
        [pupil_id] => 79571 
        [fullname] => Daniel Lacey 
        [school_id] => 1 
        [meeting_title] => 2016-10-07 14:15 
        [meeting_id] => 1816 
        [slot_id] => 87 
        [startTime] => 2016-10-07 14:25:00 
        [endTime] => 2016-10-07 14:30:00 
        [duration] => 300 
       ) 
      [5] => meeting Object (
        [errors] => 0 
        [pupil_id] => 48307 
        [fullname] => Callum Lacey 
        [school_id] => 1 
        [meeting_title] => Parent Evening 1 
        [meeting_id] => 1812 
        [slot_id] => 87 
        [startTime] => 2016-10-07 14:30:00 
        [endTime] => 2016-10-07 14:40:00 
        [duration] => 600 
       ) 
      [6] => meeting Object (
        [errors] => 0 
        [pupil_id] => 48307 
        [fullname] => Callum Lacey 
        [school_id] => 1 
        [meeting_title] => Parent Evening 3 
        [meeting_id] => 1815 
        [slot_id] => 87 
        [startTime] => 2016-10-07 14:40:00 
        [endTime] => 2016-10-07 14:50:00 
        [duration] => 600 
       ) 
      [7] => meeting Object (
        [errors] => 0 
        [pupil_id] => 79571 
        [fullname] => Daniel Lacey 
        [school_id] => 1 
        [meeting_title] => Parent Evening 3 
        [meeting_id] => 1815 
        [slot_id] => 87 
        [startTime] => 2016-10-07 14:50:00 
        [endTime] => 2016-10-07 15:00:00 
        [duration] => 600 
       ) 
     ) 
) 
+0

我希望你不張貼真​​實姓名和密碼,這裏笑 –

+0

@埃德蒙簧不,它測試數據 :) –

回答

0

如果有人想看看我是如何解決這個問題,請查看以下鏈接:

Fix to the question