title: How to generate permutaion and combination result
body: <p>i have this array</p>
  
  <pre><code>$dataArray = array
          (
          array(1,11,111),
          array(2,22,222),
          array(3,33,333),
          array(4,44,444)
      );
  </code></pre>
  
  <p>I also Google for it but no useful <code>PHP</code> script found..</p>
  
  <p><strong>Result</strong> using permutation combination method</p>
  
  <pre><code>1,11,111
  1,111,11
  11,111
  1,11,
  2,11,111
  2,11,1
  .
  .
  .
  .
  </code></pre>
  
  <p>and yes i have already tried it with permutation combination method</p>
  
  <pre><code>function permutations(array $array, $r=false)
      {
          switch (count($array)) {
              case 1:
                  return $array[0];
                  break;
          }
  
          $keys = array_keys($array);
  
          $a = array_shift($array);
          $k = array_shift($keys); // Get the key that $a had
          $b = permutations($array, 'recursing');
  
          $return = array();
          foreach ($a as $v) {
              if($v)
              {
                  foreach ($b as $v2) {
                      if($r == 'recursing')
                          $return[] = array_merge(array($v), (array) $v2);
                      else
                          $return[] = array($k =&gt; $v) + array_combine($keys, $v2);
                  }
              }
          }
  
      return $return;
  }
  
  
  $x = permutations($dataArray);      
  echo "&lt;pre&gt;";               
  print_r($x);
  </code></pre>