everisk Posted July 24, 2007 Share Posted July 24, 2007 Hi, I need to find if 2 array contains same value, if so then add their count values. For example, I have the below array. I have to add 'count' of array 0 and array 1 because the 'url' is the same (open). I have to also add 'count' of array 2 and array 3 because the 'url' is the same. Thank you in advance! Array ( [0] => Array ( [lid] => 1567 [url] => open [count] => 736 ) [1] => Array ( [lid] => 1573 [url] => open [count] => 265 ) [2] => Array ( [lid] => 1568 [url] => http://my.sony.co.th/newsletter/issue/SonyCenter_promotion/index.html [count] => 186 ) [3] => Array ( [lid] => 1575 [url] => http://my.sony.co.th/newsletter/issue/SonyCenter_promotion/index.html [count] => 73 ) ) My code that populate the array $i=0; while($row = mysql_fetch_array($table)) { //get URL name $sql2 = "select * from all_links where id=$row[lid]"; $tab2 = mysql_query($sql2) or die("Cannot get URL"); $url = mysql_fetch_array($tab2); $t_link[$i]['lid'] = $row['lid']; $t_link[$i]['url'] = $url['link']; $t_link[$i]['count'] = $row['clid']; $i++; } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.