title: A Challenge? converting mysql rows to very specific format with php
body: <p>how to format sql server rows using php that look like this:</p>
  
  <pre><code>id     company         value      monthyear
  1      companyone      30         january2012
  2      companytwo      20         february2012
  3      companyone      10         february2012
  </code></pre>
  
  <p>into this:</p>
  
  <pre><code>monthyear: ['january2012', 'february2012']
  </code></pre>
  
  <p>and this:</p>
  
  <pre><code>company: 'companyone', value: [30, 10]
  company: 'companytwo', value: [0, 20]
  </code></pre>
  
  <p>each instance of a month from the db is combined into one instance.</p>
  
  <p>company one, which has two rows, is combined into one instance where each value is lined up in order of the month.  company two, which only has one instance, has it's value defined as 0 where it has no instance in a month. </p>
  
  <p>the farthest i've gotten is are two two dimensional array with array_merge_recursive and some conditional statements but then my head goes into knots. </p>