title: php recursive increment
body: <p>I have an array like so:</p>
  
  <pre><code>Array ( [0] =&gt; 0 [1] =&gt; 0 [2] =&gt; 0 );
  </code></pre>
  
  <p>there are 3 elements (3 integers) and I want them to increment from 0 to 36;</p>
  
  <p>I understand that the best way for this is recursion because each element has to be checked to see if it is at the maximum ( 36 ) and if it is, it sets the last element to 0 and increments the previous.</p>
  
  <p>so my array basically wants to go like:</p>
  
  <pre><code>Array ( [0] =&gt; 0 [1] =&gt; 0 [2] =&gt; 0 );
  Array ( [0] =&gt; 0 [1] =&gt; 0 [2] =&gt; 1 );
  Array ( [0] =&gt; 0 [1] =&gt; 0 [2] =&gt; 2 );
  ...
  Array ( [0] =&gt; 0 [1] =&gt; 0 [2] =&gt; 36 );
  Array ( [0] =&gt; 0 [1] =&gt; 1 [2] =&gt; 0 );
  Array ( [0] =&gt; 0 [1] =&gt; 1 [2] =&gt; 1 );
  ....
  Array ( [0] =&gt; 0 [1] =&gt; 1 [2] =&gt; 36 );
  Array ( [0] =&gt; 0 [1] =&gt; 2 [2] =&gt; 0 );
  
  ETC ETC ETC
  </code></pre>
  
  <p>But I've got no idea how to do this recursively!</p>
  
  <p>However the solution also needs to work for 4 elements and 5 elements and 6 etc etc!</p>
  
  <p>Can anybody give me some direction?</p>