title: PHP: Counting values in an array of objects
body: <p>I have a databse class which returns an array of objects. I am trying to get multiple bits of data from this single query, in order to prevent having to run three queries.</p>
  
  <p>I have stumbled upon <code>array_count_values()</code> [ <a href="http://uk3.php.net/manual/en/function.array-count-values.php" rel="nofollow">http://uk3.php.net/manual/en/function.array-count-values.php</a> ] which will be perfect for catching various bits of data about the result set which I can use. Although I can't figure out how to cast all the second dimensions into arrays without having to just foreach through the whole return which would be a little bad I think.</p>
  
  <p>Does anyone have any ideas how I can convert my array of objects, as a whole into an array, to allow this game changing function to do it's magic?</p>
  
  <pre><code>Array
  (
      [0] =&gt; stdClass Object
          (
              [message_id] =&gt; 23185
              [from_profile] =&gt; 3165
              [to_profile] =&gt; 962
              [parent_message_id] =&gt; 17111
              [date_sent] =&gt; 2011-02-23 05:48:25
              [subject] =&gt; RE: hi
          )
  // etc
  </code></pre>
  
  <p>There is also the issue that I've just thought of whilst typing this question, sods law eh? That will the function be able to parse multiple dimensions?</p>