title: How to get total hours from start time and end time with multi dimensional array along with over lapping check?
body: <p>I have a below scenario where I need to check for the <strong>overlapping</strong> with-in a specific date array only and get total attended hours.</p>
  <pre><code>array (
    '2020-07-14' =&gt; 
    array (
      'total_attended_hours' =&gt; 0,
      0 =&gt; 
      array (
        'start_time' =&gt; '09:00:00',
        'end_time' =&gt; '13:00:00',
        'hours' =&gt; '4 hours 0 mins',
      ),
      1 =&gt; 
      array (
        'start_time' =&gt; '13:30:00',
        'end_time' =&gt; '16:30:00',
        'hours' =&gt; '3 hours 0 mins',
      ),
      2 =&gt; 
      array (
        'start_time' =&gt; '09:00:00',
        'end_time' =&gt; '14:00:00',
        'hours' =&gt; '5 hours 0 mins',
      ),
    ),
    '2020-07-15' =&gt; 
    array (
      'total_attended_hours' =&gt; 0,
      0 =&gt; 
      array (
        'start_time' =&gt; '13:30:00',
        'end_time' =&gt; '17:00:00',
        'hours' =&gt; '3 hours 30 mins',
      ),
      1 =&gt; 
      array (
        'start_time' =&gt; '09:00:00',
        'end_time' =&gt; '14:00:00',
        'hours' =&gt; '5 hours 0 mins',
      ),
    ),
  )
  </code></pre>
  <p>As in the above example with date <code>2020-07-14</code> we have <code>start_time and </code>end_time<code>:- </code>total_attended_hours<code>should be equals to</code>7 hours 30 mins``</p>
  <p>And for next <code>2020-07-15</code> it should be <code>total_attended_hours</code> = <code>8 hours 0 mins</code></p>
  <p><a href="https://paiza.io/projects/79afOovCtzTpgsjvtrM_TQ" rel="nofollow noreferrer">Playground</a></p>
  <p><strong>New issue with below array</strong></p>
  <pre><code>
  $data = [
    '2020-07-14' =&gt; 
    [
      [
        'start_time' =&gt; '14:15:00',
        'end_time' =&gt; '17:45:00',
      ],[
        'start_time' =&gt; '14:30:00',
        'end_time' =&gt; '17:30:00',
      ],[
        'start_time' =&gt; '14:30:00',
        'end_time' =&gt; '17:30:00',
      ],
    ],
    '2020-07-15' =&gt; [
      [
        'start_time' =&gt; '13:30:00',
        'end_time' =&gt; '17:00:00',
      ],[
        'start_time' =&gt; '09:00:00',
        'end_time' =&gt; '14:00:00',
      ],
    ],
  ];
  </code></pre>
  <p>Result :-</p>
  <pre><code>Array
  (
      [2020-07-14] =&gt; Array
          (
              [0] =&gt; Array
                  (
                      [start_time] =&gt; 14:15:00
                      [end_time] =&gt; 17:45:00
                  )
  
              [1] =&gt; Array
                  (
                      [start_time] =&gt; 14:30:00
                      [end_time] =&gt; 17:30:00
                  )
  
              [2] =&gt; Array
                  (
                      [start_time] =&gt; 14:30:00
                      [end_time] =&gt; 17:30:00
                  )
  
              [total_attended_hours] =&gt; 03:15:00
          )
  </code></pre>
  <p>Where as <code>[total_attended_hours] =&gt; 03:15:00</code> should be <code>[total_attended_hours] =&gt; 03:30:00</code></p>