creating a "deck of cards" based on rarity
<p>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:</p>

<pre><code>Array
(
    [0] =&gt; Array
        (
            [image] =&gt; photo1.jpg
            [rarity] =&gt; common
        )

    [1] =&gt; Array
        (
            [image] =&gt; photo2.jpg
            [rarity] =&gt; uncommon
        )
    .
    .
    .

    [x] =&gt; Array
        (
            [image] =&gt; photo(x).jpg
            [rarity] =&gt; rare
        )
)
</code></pre>

<p>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.</p>

<p>EDIT FOR CLARIFICATION:  Each image in the array can only occur in the final deck once. </p>
