title: Count unique value from associative array
body: <p>First, thanks for any help.</p>
  
  <p>I've spent countless hours on here and other forums trying to find my exact solution but either 1) I'm not understanding the one's I've read or 2)I haven't found the right answer.</p>
  
  <p>In PHP, I've run a somewhat complex query which returns a set of records similar to:</p>
  
  <pre><code>id | name | direction| 
  1    aaa    east
  2    bbb    west
  3    ccc    east
  </code></pre>
  
  <p>I've created an associative array such as:</p>
  
  <pre><code>$query=("select * from foo");
  $result=mysql_query($query);
  $array=mysql_fetch_assoc($result);
  </code></pre>
  
  <p>Now, what I need to do seems simple but I'm not grasping the concept for some reason.
  I need to loop through the entire $array and return a count of any value that I want to specify and store that count in a variable.</p>
  
  <p>i.e. Show me how many times <em>east</em> shows up in the "direction" column and put that in a variable called <code>$eastcount</code>.</p>
  
  <p>I've tried various combinations of using <code>foreach</code> loops with incremental counts and have tried using <code>array_count_values</code> but have not been able to put the pieces together :/</p>