title: Generate array of unique values in specific array column
body: <p>I'm getting the desired results back from my query and now I'm having trouble figuring 
  out how to manipulate the data into something usable.</p>
  
  <p>The ultimate goal is a json output to be used by google charts and I can do this on
  any one single component without a problem.</p>
  
  <p>I need the output to look like this (I have no idea how many components will come after 
  Month/Year... it might be 0 or 10 or 20...):</p>
  
  <pre><code>      ['Month/Year', 'Wiper Blades', 'Mufflers'] [,[...]],
        ['March 2013',  13,      11],
        ['April 2013',  17,      19],
        [...],
        [...]
        ]);
  </code></pre>
  
  <p>Here is the array I have after my query ( can't do this in a while() because I need
  the cmpnt_name for the first line of the desired output (above) which is why I'm building the array first):</p>
  
  <pre><code>Array
  (
    [0] =&gt; Array
        (
            [vmonth] =&gt; February
            [vyear] =&gt; 2013
            [cmpnt_count] =&gt; 9
            [cmpnt_name] =&gt; Wiper blade
        )
  
    [1] =&gt; Array
        (
            [vmonth] =&gt; March
            [vyear] =&gt; 2013
            [cmpnt_count] =&gt; 13
            [cmpnt_name] =&gt; Wiper blade
        )
  
    [2] =&gt; Array
        (
            [vmonth] =&gt; March
            [vyear] =&gt; 2013
            [cmpnt_count] =&gt; 11
            [cmpnt_name] =&gt; Muffler
        )
  
    [3] =&gt; Array
        (
            [vmonth] =&gt; April
            [vyear] =&gt; 2013
            [cmpnt_count] =&gt; 17
            [cmpnt_name] =&gt; Wiper blade
        )
  
    [4] =&gt; Array
        (
            [vmonth] =&gt; April
            [vyear] =&gt; 2013
            [cmpnt_count] =&gt; 19
            [cmpnt_name] =&gt; Muffler
        )
  )
  </code></pre>
  
  <p>I can't loop through the array and take every cmpnt_name and append that to the 
  first line of the desired output... I only want uniques.</p>
  
  <p>Also a component may not have any views for a given month (it may not have even 
  existed that month) so I may have components that date from Feb and other components 
  that don't get added until later but are included in the count... i.e. Muffler was added
  in March. </p>
  
  <p>So how do I go about finding the unique component names for the first row?</p>
  
  <p>I was thinking: </p>
  
  <pre><code>function findUniques($cmpnt)
  {
    $names = array();
    foreach($cmpnt as $item)
    {
      $key = $item['cmpnt_name'];
      if(array_key_exists($key, $names))
      {
        $names[$key]++;
      }
      else
        $names[$key] = 1;
    }
    return($names);
  }
  </code></pre>
  
  <p>Is there a php function for this?</p>
  
  <p>Is there a better way to do this?</p>