title: Which function can replace multiple nested loops in php?
body: <p>I work on a family-tree function, and I need to iterate a <code>for()</code> statement for each generation.</p>
  
  <p>I don't know the number of generation in advance and all <code>for()</code> statements will contain almost the same script...</p>
  
  <pre><code>$nb_parents_line1 = 1;
  for($i = 0 ; $i &lt; $nb_parents_line1 ; $i++) {
  
      $nb_parents_line2 =  $nb_son[$i];
      for($i2 = 0 ; $i2 &lt; $nb_parents_line2 ; $i2++) {/*for each son of each parent*/
  
          $nb_parents_line3 = ;
          for($i3 = 0 ; $i3 &lt; $nb_parents_line3 ; $i3++) {/*for each son of each son of each parent*/
  
              $nb_parents_line4 = ;
              for($i4 = 0 ; $i4 &lt; $nb_parents_line4 ; $i4++) {/*and so on...*/
  
              }
              /*center*/
          }
      /*code for center*/
      }
  /*code for center*/
  }
  </code></pre>
  
  <p>Is there a easiest way to do such a two dimensional for ?
  Is there a way for having just as <code>for()</code> as I need ?</p>