title: Get all combinations from multiple nested arrays
body: <p>I'm trying to come up with an algorithm in PHP to get all the combinations for a nested array:</p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [0] =&gt; Option Object
                  (
                      [strValue] =&gt; rough
                  )
  
              [1] =&gt; Option Object
                  (
                      [strValue] =&gt; smooth
                  )
  
              [2] =&gt; Option Object
                  (
                      [strValue] =&gt; coarse
                  )
  
          )
  
      [1] =&gt; Array
          (
              [0] =&gt; Option Object
                  (
                      [strValue] =&gt; shiney
                  )
  
              [1] =&gt; Option Object
                  (
                      [strValue] =&gt; mat
                  )
  
          )
  
      [2] =&gt; Array
          (
              [0] =&gt; Option Object
                  (
                      [strValue] =&gt; Large
                  )
  
              [1] =&gt; Option Object
                  (
                      [strValue] =&gt; Medium
                  )
  
              [2] =&gt; Option Object
                  (
                      [strValue] =&gt; Small
                  )
  
              [3] =&gt; Option Object
                  (
                      [strValue] =&gt; very large
                  )
  
          )
  
  )
  </code></pre>
  
  <p>So I would get something back like:</p>
  
  <p>-rough, shiney, Large</p>
  
  <p>-rough, shiney, Small</p>
  
  <p>-rough, shiney, Medium</p>
  
  <p>-rough, shiney, Very Large</p>
  
  <p>-smooth, shiney, Large</p>
  
  <p>-smooth, shiney, Small</p>
  
  <p>-smooth, shiney, Medium</p>
  
  <p>-smooth, shiney, Very Large</p>
  
  <p>etc (should be 24 in this example)</p>
  
  <p>I've tried through various foreach examples and some basic recursive function, but I seem to be getting no where fast. If anyone could give a basic outline of how to solve this I'd be very grateful, thanks! </p>