Making an easy way of getting the value I need in PHP?
<p>I am making a game in php as a personal project.</p>

<p>I can make items out of items that I have, the items I have are stored in an array called <code>$user</code></p>

<p>For now I am displaying how many of each item I can make by doing the following (let us say that to make a spade you need 1 wood and 1 metal and 1 energy)</p>

<pre><code>$amount = min($user['wood'], $user['metal'], $user['energy']);
// USER HAS ITEMS TO MAKE SPADE
if ($amount) {
     echo '&lt;form class="spacerTop" action="#" method="post"&gt;
     &lt;input type="hidden" name="itemPlus" value="spade" /&gt;
     &lt;select name="amount"&gt;';
     $i = 1;
     while ($i &lt;= $amount) {
          echo '&lt;option value"' . $i . '"&gt;' . $i . '&lt;/option&gt;';
     ++$i;
     }
     echo '&lt;/select&gt;
     &lt;input type="submit" value="Make Spades" /&gt;
     &lt;/form&gt;';
}
</code></pre>

<p>Doing the above will only show the option to make a spade if the user has the minimum amount of items to make a spade. It will also show in a <code>form select</code> how many spades they can make in total using the <code>min</code> value from php.</p>

<p>What I cannot work out is say if it costs 2 energy, 10 wood and 5 metal? How can I get the same functionality as above even if the items it costs to make an item differs?</p>
