Most efficient filing
<p>The situation is that i have to fill rooms with a <em>x</em> number of persons.
For this example lets use:</p>

<pre><code>$persons = 7;
</code></pre>

<p>And i got a array with:</p>

<pre><code>$differentRoom = array(
    'Room 1' =&gt; 1, //This room fits 1 person
    'Room 2' =&gt; 2, //This room fits 2 persons
    'Room 3' =&gt; 3, //This room fits 3 persons
);
</code></pre>

<p>Now i want that PHP makes combinations that is exactly 7 in the shortest way. The result have to be, you need : 'Room3' 'Room 3' 'Room 1'</p>

<p>in another example i have</p>

<pre><code>$persons = 15;
</code></pre>

<p>And a array with</p>

<pre><code>$differentRooms = array(
    'Room 1' =&gt; 4, // This room fits x persons
    'Room 2' =&gt; 7,
);
</code></pre>

<p>This time a combination can't be exactly 15.
In this situation the result have to be a combination that is more then 15.
In this case it would be 16. 16 is nearest to 10, and the result have to be. You need : 'Room 2''Room 2' 'Room 1'</p>

<p>How can i do this?</p>
