Have an Array Check for mutiple types.

Hi so basically say I have 4 items built of beads (A), there are 8 types of individual beads (B). I want to check this array for any if any of the 4 items i added in an amount have the same bead.

So if item 2 and 4 contain both contain bead 3 then add together any of the variables attached under the bead name.

How would i search my own array for items with the same name then add the variables together and output it?

Thanks