title: How to shift elements in array php
body: <p>I´m doing timetable for school. I already have selected data from DB, but all data are represented at the beginning-at 7,10am(pict 1). But some lesson starts at 7,10, others starts at 8am. I have no idea how these data shift if the lessons starts f.e at 8am. I found php function array_unshift, but actually do I need add some elements on the beginning? 
  I need to shift the data if the start_time of the lessons is not equal to start_time(top row on the picture) 
  <a href="http://i.stack.imgur.com/Y0MWN.png" rel="nofollow">pict 1</a></p>
  
  <p>I did it with foreach loop and the array which represent timetable is:
  <code>$timetable[$day]['lessons'][$z]['dividedlessons'][$q]['start_time']</code></p>
  
  <p><code>$z</code> is index for individual lesson - on the pic 0,1,2,3,4; 
  divided lessons mean when students have 2 different lesson in one lesson hour;
  and <code>$q</code> is index for divided lesson; listofhours is 07:10, 08:00, 08:50,etc.  </p>
  
  <pre><code>    Array ( [start_time] =&gt; 0000-00-00 08:00:00 [end_time] =&gt; 0000-00-00 08:45:00 [group] =&gt; [name] =&gt; BIO [room] =&gt; CP [lector] =&gt; Reh ) 
  Array ( [start_time] =&gt; 0000-00-00 08:50:00 [end_time] =&gt; 0000-00-00 09:35:00 [group] =&gt; [name] =&gt; MAT [room] =&gt; CP [lector] =&gt; Ĺ af ) 
  Array ( [start_time] =&gt; 0000-00-00 09:55:00 [end_time] =&gt; 0000-00-00 10:40:00 [group] =&gt; [name] =&gt; SLJ [room] =&gt; CP [lector] =&gt; Bal ) 
  Array ( [start_time] =&gt; 0000-00-00 10:45:00 [end_time] =&gt; 0000-00-00 11:30:00 [group] =&gt; [name] =&gt; ANJ [room] =&gt; CP [lector] =&gt; Ĺ Ăˇn  
  Array ( [start_time] =&gt; 0000-00-00 11:40:00 [end_time] =&gt; 0000-00-00 12:25:00 [group] =&gt; [name] =&gt; FYZ [room] =&gt; BF [lector] =&gt; Kis ) 
  Array ( [start_time] =&gt; 0000-00-00 12:35:00 [end_time] =&gt; 0000-00-00 13:20:00 [group] =&gt; 1.sk [name] =&gt; INF [room] =&gt; AI [lector] =&gt; 
  Haj )
  Array ( [start_time] =&gt; 0000-00-00 12:35:00 [end_time] =&gt; 0000-00-00 13:20:00 [group] =&gt; ETV [name] =&gt; ETV [room] =&gt; CP [lector] =&gt; Cse ) 
  Array ( [start_time] =&gt; 0000-00-00 13:30:00 [end_time] =&gt; 0000-00-00 14:15:00 [group] =&gt; 2.sk. [name] =&gt; INF [room] =&gt; AI [lector] =&gt; Haj ) 
  
  Array ( [start_time] =&gt; 0000-00-00 08:00:00 [end_time] =&gt; 0000-00-00 08:45:00 [group] =&gt; [name] =&gt; ANJ [room] =&gt; CP [lector] =&gt; Ĺ Ăˇn ) 
  Array ( [start_time] =&gt; 0000-00-00 08:50:00 [end_time] =&gt; 0000-00-00 09:35:00 [group] =&gt; [name] =&gt; MAT [room] =&gt; CP [lector] =&gt; Ĺ af ) 
  Array ( [start_time] =&gt; 0000-00-00 09:55:00 [end_time] =&gt; 0000-00-00 10:40:00 [group] =&gt; [name] =&gt; DEJ [room] =&gt; CP [lector] =&gt; Str ) 
  Array ( [start_time] =&gt; 0000-00-00 10:45:00 [end_time] =&gt; 0000-00-00 11:30:00 [group] =&gt; [name] =&gt; GEO [room] =&gt; CP [lector] =&gt; StK ) 
  Array ( [start_time] =&gt; 0000-00-00 11:40:00 [end_time] =&gt; 0000-00-00 12:25:00 [group] =&gt; [name] =&gt; TSV [room] =&gt; T1 [lector] =&gt; Cse ) 
  Array ( [start_time] =&gt; 0000-00-00 12:35:00 [end_time] =&gt; 0000-00-00 13:20:00 [group] =&gt; [name] =&gt; SLJ [room] =&gt; CP [lector] =&gt; Bal ) 
  
  Array ( [start_time] =&gt; 0000-00-00 08:00:00 [end_time] =&gt; 0000-00-00 08:45:00 [group] =&gt; [name] =&gt; SLJ [room] =&gt; CP [lector] =&gt; Bal ) 
  Array ( [start_time] =&gt; 0000-00-00 08:50:00 [end_time] =&gt; 0000-00-00 09:35:00 [group] =&gt; [name] =&gt; MAT [room] =&gt; CP [lector] =&gt; Ĺ af ) 
  Array ( [start_time] =&gt; 0000-00-00 09:55:00 [end_time] =&gt; 0000-00-00 10:40:00 [group] =&gt; [name] =&gt; ANJ [room] =&gt; CP [lector] =&gt; Ĺ Ăˇn ) 
  Array ( [start_time] =&gt; 0000-00-00 10:45:00 [end_time] =&gt; 0000-00-00 11:30:00 [group] =&gt; [name] =&gt; OBN [room] =&gt; CP [lector] =&gt; Kis )
  Array ( [start_time] =&gt; 0000-00-00 11:40:00 [end_time] =&gt; 0000-00-00 12:25:00 [group] =&gt; [name] =&gt; VYV [room] =&gt; CP [lector] =&gt; Reh ) 
  Array ( [start_time] =&gt; 0000-00-00 12:35:00 [end_time] =&gt; 0000-00-00 13:20:00 [group] =&gt; [name] =&gt; NEJ [room] =&gt; CP [lector] =&gt; Til ) 
  
  Array ( [start_time] =&gt; 0000-00-00 08:00:00 [end_time] =&gt; 0000-00-00 08:45:00 [group] =&gt; [name] =&gt; ANJ [room] =&gt; CP [lector] =&gt; Ĺ Ăˇn ) 
  Array ( [start_time] =&gt; 0000-00-00 08:50:00 [end_time] =&gt; 0000-00-00 09:35:00 [group] =&gt; [name] =&gt; TSV [room] =&gt; T1 [lector] =&gt; Cse ) 
  Array ( [start_time] =&gt; 0000-00-00 09:55:00 [end_time] =&gt; 0000-00-00 10:40:00 [group] =&gt; [name] =&gt; MAT [room] =&gt; CP [lector] =&gt; Ĺ af )
  Array ( [start_time] =&gt; 0000-00-00 10:45:00 [end_time] =&gt; 0000-00-00 11:30:00 [group] =&gt; [name] =&gt; SLJ [room] =&gt; CP [lector] =&gt; Bal ) 
  Array ( [start_time] =&gt; 0000-00-00 11:40:00 [end_time] =&gt; 0000-00-00 12:25:00 [group] =&gt; [name] =&gt; CHE [room] =&gt; CP [lector] =&gt; Ĺ af ) 
  Array ( [start_time] =&gt; 0000-00-00 12:35:00 [end_time] =&gt; 0000-00-00 13:20:00 [group] =&gt; NAV [name] =&gt; NAV [room] =&gt; [lector] =&gt; Kub ) 
  
  Array ( [start_time] =&gt; 0000-00-00 08:00:00 [end_time] =&gt; 0000-00-00 08:45:00 [group] =&gt; [name] =&gt; MAT [room] =&gt; CP [lector] =&gt; Ĺ af ) 
  Array ( [start_time] =&gt; 0000-00-00 08:50:00 [end_time] =&gt; 0000-00-00 09:35:00 [group] =&gt; [name] =&gt; SLJ [room] =&gt; CP [lector] =&gt; Bal ) 
  Array ( [start_time] =&gt; 0000-00-00 09:55:00 [end_time] =&gt; 0000-00-00 10:40:00 [group] =&gt; [name] =&gt; TSV [room] =&gt; T1 [lector] =&gt; Cse ) 
  Array ( [start_time] =&gt; 0000-00-00 10:45:00 [end_time] =&gt; 0000-00-00 11:30:00 [group] =&gt; [name] =&gt; BIO [room] =&gt; CP [lector] =&gt; Reh ) 
  Array ( [start_time] =&gt; 0000-00-00 11:40:00 [end_time] =&gt; 0000-00-00 12:25:00 [group] =&gt; [name] =&gt; CHE [room] =&gt; CP [lector] =&gt; Til ) 
  Array ( [start_time] =&gt; 0000-00-00 12:35:00 [end_time] =&gt; 0000-00-00 13:20:00 [group] =&gt; [name] =&gt; HUV [room] =&gt; CP [lector] =&gt; Bal ) 
  </code></pre>
  
  <p>'skratka' is abbrevation for days; 'hodiny' is lessons and 'delenehodiny' is dividedlesson.. </p>
  
  <p><a href="http://i.stack.imgur.com/pgP8H.png" rel="nofollow">DB</a></p>
  
  <p>I tried explain it clearly I hope you will understand :) Thank you!  </p>