Show how many times values are in an array
<p>The php code below displays the country location of the IPs stored in a database and outputs it in an HTML table. As is, it creates a long list of the country code for each individual IP.</p>

<p>For example...</p>

<p>US<br>US<br>MX<br>US</p>

<p>What I would like to do is, rather than create a long list of each individual item, display the number of times an item shows up in the array. Using the example above...</p>

<p>country frequency</p>

<p>US 3 <br>MX 1</p>

<p>How would I implement this? Here's the full code...</p>

<pre><code>require_once("geoip.inc");
$gi = geoip_open("GeoIP.dat",GEOIP_STANDARD);


include_once($_SERVER['DOCUMENT_ROOT'] . 'connect.php'); 

/* Performing SQL query */
 $data = mysql_query("SELECT * FROM the_ips LIMIT 100")
 or die(mysql_error());

 echo "&lt;table&gt;";
 echo "&lt;td&gt;&lt;strong&gt;Country&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&lt;strong&gt;Frequency&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;";

 while($info = mysql_fetch_array( $data ))
     {
      $ip = $info['ip_address'];
      $country_code = geoip_country_code_by_addr($gi, $ip);
      $countrylist = array($country_code);
      $frequency = array_count_values($countrylist);

      echo "&lt;tr&gt;&lt;td style='width: 100px;'&gt;".$country_code."&lt;/td&gt;&lt;td style='width: 100px;'&gt;".$frequency."&lt;/td&gt;&lt;/tr&gt;";
     }
 echo "&lt;/table&gt;";
 geoip_close($gi);
</code></pre>

<p>I need to assign <code>$frequency</code> and remove rows that include duplicate "Country" value, but not sure how to do this. As is, $frequency returns "Array" when I was hoping for a number (i.e. US 3).</p>
