title: sort array to table by 2 parameters
body: <p>I have an array. And I try to group it to a such table. </p>
  
  <pre><code>-------------------------------------------------------------
            | 2014-01-21 | 2014-01-22 | 2014-01-23 | 2014-01-27 
  -------------------------------------------------------------      
  title1    |     50     |      5     |    20+7    |     0    |  
  -------------------------------------------------------------
  title2    |     40     |     20     |      0     |     0    |  
  ------------------------------------------------------------
  title3    |      0     |      0     |     40     |     40   |  
  -------------------------------------------------------------
  title4    |      0     |      0     |      4     |     0    |  
  -------------------------------------------------------------
  </code></pre>
  
  <p>i.e. I want to group to table by "title" and "date" and sum by third parameter.</p>
  
  <pre><code>$items_arr =(
  [0] =&gt; Array(  [1] =&gt; title1   [2] =&gt; 2014-01-21   [3] =&gt; 50)
  [1] =&gt; Array(  [1] =&gt; title1   [2] =&gt; 2014-01-22   [3] =&gt; 5)
  [2] =&gt; Array(  [1] =&gt; title1   [2] =&gt; 2014-01-23   [3] =&gt; 7)
  [3] =&gt; Array(  [1] =&gt; title1   [2] =&gt; 2014-01-23   [3] =&gt; 20)
  [4] =&gt; Array(  [1] =&gt; title2   [2] =&gt; 2014-01-21   [3] =&gt; 40)
  [5] =&gt; Array(  [1] =&gt; title2   [2] =&gt; 2014-01-22   [3] =&gt; 20)
  [6] =&gt; Array(  [1] =&gt; title3   [2] =&gt; 2014-01-23   [3] =&gt; 40)
  [7] =&gt; Array(  [1] =&gt; title3   [2] =&gt; 2014-01-27   [3] =&gt; 40)
  [8] =&gt; Array(  [1] =&gt; title4   [2] =&gt; 2014-01-23   [3] =&gt; 4)
  )
  
  
  for($i=0; $i&lt;($numworks); $i++)
  { 
      echo "&lt;tr&gt;&lt;td&gt;". $works_arr[$i]."&lt;/td&gt;"; 
      for($j=0; $j&lt;$numitems; $j++){ 
        if (($works_arr[$i] == $items_arr[$j][1])){ 
          echo "&lt;td&gt;".$items_arr[$j][3]."&lt;/td&gt;"; 
        }else{ echo "&lt;td&gt;0&lt;/td&gt;"; } 
       }; 
       echo "&lt;/tr&gt;"; 
   }
  </code></pre>
  
  <p>Where $numitems is number elements at $items_arr.</p>
  
  <pre><code>$numworks at  $works_arr Array([0] =&gt; title1 [1] =&gt; title2 [2] =&gt; title3 [3] =&gt; title4)
  </code></pre>