Process for getting top 10 for each field //get uids of all friends //Call MySQL fields for all friends //explode strings by commas //merge arrays $count = array(); //foreach element: foreach( $arr as $val ) //add 1 to the hash of that element(no idea how): $count[$val]++; //sort desc: arsort($count); //chop of everything but top 10: array_slice($count, 0, 10); //display