title: How to do SQL's GROUP BY using PHP?
body: <p>I'd like to SELECT rows from a database table and group them using PHP instead of SQL based on a parameter (in this case by item).</p>
  
  <p>SQL:</p>
  
  <pre><code>Clothes table
  
   id  item     owner
   1   shoes     joe 
   2   pants     joe
   3   hat       joe
   4   pants     joe
   5   hat       tom
  
  SELECT * from Clothes where owner='joe'
  
   1   shoes     joe 
   2   pants     joe
   3   hat       joe
   4   pants     joe
  </code></pre>
  
  <p>Here's how I'd like the results to look after using PHP instead of SQL's <code>GROUP BY item</code></p>
  
  <p>PHP :</p>
  
  <pre><code> 1   shoes     joe 
   2   pants     joe   //count 2
   3   hat       joe
  </code></pre>
  
  <p>I'm sure there is a PHP array function for this I'm just not familiar, thoughts?    </p>