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 foreach element add 1 to the hash of that element(no idea how) sort desc chop of everything but top 10 display