Skip to content

Instantly share code, notes, and snippets.

@imjacobclark
Created April 14, 2013 00:54
Show Gist options
  • Save imjacobclark/5380851 to your computer and use it in GitHub Desktop.
Save imjacobclark/5380851 to your computer and use it in GitHub Desktop.
Sources
<?php
$conn = new Mongo('localhost');
$db = $conn->tweetograph;
$collection = $db->biebertweetTest;
$cursor = $collection->find();
$tweetArray = array();
foreach ($cursor as $obj) {
array_push($tweetArray, $obj['source']);
}
$counted = array_count_values($tweetArray);
arsort($counted);
echo "Total Tweets queried: <strong>".$cursor->count()."</strong><br/><br/>";
echo "
<table border=1>
<tr>
<th>Source</th>
<th>Count</th>
</tr>
";
foreach ($counted as $key => $value) {
echo "
<tr>
<td>".trim(preg_replace('/ +/', ' ', preg_replace('/[^A-Za-z0-9 ]/', ' ', urldecode(html_entity_decode(strip_tags($key))))))."</td>
<td>".trim(preg_replace('/ +/', ' ', preg_replace('/[^A-Za-z0-9 ]/', ' ', urldecode(html_entity_decode(strip_tags($value))))))."</td>
</tr>
";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment