title: Complex Array to Compare Armor Sets
body: <p>perhaps I'm having a dumb moment, but I just can't seem to work this out in my head.</p>
  
  <p>I'll try and explain:-</p>
  
  <p>I have three 'sets.' Each set contains 6 objects. I need a loop (or series of nested loops) to result every combination of these sets.</p>
  
  <p>It's for a game, I'm trying to write a script to compare armor sets - sad I know. The array of sets looks like this:-</p>
  
  <pre><code>class =&gt; array(
    set1 =&gt; array(
      hat item =&gt; array(stats)
      glove item =&gt; array(stats)
      ...
    set2 =&gt; array(
      hat item =&gt; array(stats)
      ...
    set3 =&gt; array(
      ...
  
  )
  </code></pre>
  
  <p>This may be a lot simpler (or a lot more difficult?) than I thought.</p>
  
  <p>Ideas welcome!</p>
  
  <p>Thanks,
  Ruu.</p>
  
  <p>EDIT:-</p>
  
  <p>Ok here's an array sample, I've stripped out a LOT of the extra stats, and just left one for each piece:-</p>
  
  <pre><code>$setinfo = array(
      'rk' =&gt; array(
          'set1' =&gt; array(
              'hat' =&gt; array(
                  'will' =&gt; 114,
              ),
              'shoulders' =&gt; array(
                  'will' =&gt; 78,
              ),
              'shirt' =&gt; array(
                  'will' =&gt; 78,
              ),
              'gloves' =&gt; array(
                  'will' =&gt; 78,
              ),
              'trousers' =&gt; array(
                  'will' =&gt; 78,
              ),
              'boots' =&gt; array(
                  'will' =&gt; 114,
              ),
          ),
          'set2' =&gt; array(
              'hat' =&gt; array(
                  'will' =&gt; 78,
              ),
              'shoulders' =&gt; array(
                  'will' =&gt; 78,
              ),
              'shirt' =&gt; array(
                  'will' =&gt; 114,
              ),
              'gloves' =&gt; array(
                  'will' =&gt; 78,
              ),
              'trousers' =&gt; array(
                  'will' =&gt; 114,
              ),
              'boots' =&gt; array(
                  'will' =&gt; 78,
              ),
          ),
          'set3' =&gt; array(
              'hat' =&gt; array(
                  'will' =&gt; 78,
              ),
              'shoulders' =&gt; array(
                  'will' =&gt; 114,
              ),
              'shirt' =&gt; array(
                  'will' =&gt; 78,
              ),
              'gloves' =&gt; array(
                  'will' =&gt; 114,
              ),
              'trousers' =&gt; array(
                  'will' =&gt; 78,
              ),
              'boots' =&gt; array(
                  'will' =&gt; 78,
              ),
          ),
      )
  );
  </code></pre>
  
  <p>From this example (I will worry about comparing other stats later,) the 'ideal' pieces would be, the hat and boots from set1, with the shirt and trousers from set2, and the gloves and shoulders from set3.</p>
  
  <p>My query is how best to work out a loop which can generate a 'result' array with every permutation, for comparison later.</p>