Created
April 14, 2013 00:54
-
-
Save imjacobclark/5380851 to your computer and use it in GitHub Desktop.
Sources
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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