title: Calculate pay periods based on 14 day pay period - PHP/SQL
body: <p>I have a database that collects user input on their time in/out. I am collecting this information like so:</p>
  
  <pre><code>user_id     clock_in    clock_out
  612         1383710400  1383728400
  612         1384315200  1384333200
  508         1383710400  1383738400
  </code></pre>
  
  <p>While looping, I calculate the hours of each object like so:<br />
  <code>$total=(($e-&gt;clock_out-$e-&gt;clock_in)/60/60);</code></p>
  
  <p><b>Where I am stuck</b>
  I'm a bit stuck on how to group them into pay periods. I know that there are 26 pay periods in a year. I also know our starting pay period for this year was <code>01.13.14 - 01.26.14</code>.</p>
  
  <p><b>What I have tried:</b>
  I thought to try just gathering the week of the year <code>date('W',$e-&gt;clock_in)</code> while looping through the database results but I am not sure how to group them. </p>
  
  <p><b>Question:</b> 
  Is grouping/sorting possible while looping during a <code>foreach</code>? Do you suggest a different approach on grouping/sorting the data into pay periods? </p>
  
  <p>Please let me know if more code is needed, etc. Thank you!</p>