Choosing Array Entry Based On The Entry's Variables?

So I’m setting up some loot tables, and several factors will determine which item drops. Character class, character level, monster level, etc. My question is, is there a method for randomly choosing an item from an array, but after checking for items within that array that meet certain parameters? For instance, choosing to drop 1 of 10 possible weapons, but filtering out any that have an item level higher than the player level.