I have an array of images. Each image has a "rarity" key that tells me whether it's "common", "uncommon", or "rare". So for instance, the array might look something like this:
Array
(
[0] => Array
(
[image] => photo1.jpg
[rarity] => common
)
[1] => Array
(
[image] => photo2.jpg
[rarity] => uncommon
)
.
.
.
[x] => Array
(
[image] => photo(x).jpg
[rarity] => rare
)
)
I want to select 'y' number of images from the list, almost like creating a deck of cards, but with images instead. The rarity, of course, defines how likely that card will be selected. How do I go about doing this? I figure I start with array_rand(), but am stuck as to where to go with it.
EDIT FOR CLARIFICATION: Each image in the array can only occur in the final deck once.