What i am trying to do is get an array output of list of referrers saved in db for a certain link. i got it so far but am unable to get teh count of same referrers instead of displaying them again and again.
Here is the function i wrote :
<?php
function get_links_ref($astats) {
$sExistedLink= '';
$sMyLinkSQL = "SELECT * FROM `log` WHERE `shorturl`='{$astats}' ORDER BY `click_id` DESC";
$aLinks = $GLOBALS['oSysDB']->getAll($sMyLinkSQL);
foreach ($aLinks as $astats => $aLinkInfo) {
$reff = $aLinkInfo['referrer'];
$areff = parse_url($reff);
if($areff['host'] == 't.co' || $areff['host'] == 'www.twitter.com' || $areff['host'] == 'api.twitter.com'){
$areff['host'] = "Twitter";
}
if($areff['host'] == 'www.facebook.com' || $areff['host'] == 'm.facebook.com'){
$areff['host'] = "Facebook";
}
if($areff['host'] == 'bit.ly' || $areff['host'] == 'lilink.it'){
$areff['host'] = "Direct";
}
$sExistedLink .= <<<EOF
<p>{$areff['host']}</p>
EOF;
}
return $sExistedLink;
}
In return i get a list like this as example :
Facebook
Twitter
Facebook
Facebook
Twitter
Is it possible to edit this code as i can get something like this , count of total of same referrer in brackets
Facebook (3)
Twitter (2)
Using your exact code with small modifications