title: PHP: How to get all possible combinations of 1D array?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1256117/algorithm-that-will-take-numbers-or-words-and-find-all-possible-combinations">algorithm that will take numbers or words and find all possible combinations</a><br>
    <a href="https://stackoverflow.com/questions/1679605/combinations-dispositions-and-permutations-in-php">Combinations, Dispositions and Permutations in PHP</a>  </p>
  </blockquote>
  
  
  
  <p>I've read/tried alot of the suggested answers on SO, which none of them solves the problem</p>
  
  <pre><code>$array = array('Alpha', 'Beta', 'Gamma');
  </code></pre>
  
  <p>How to get all possible combinations?</p>
  
  <p>Expected output:</p>
  
  <pre><code>array('Alpha',
        'Beta',
        'Gamma',
        'Alpha Beta',
        'Alpha Gamma',
        'Beta Alpha',
        'Beta Gamma',
        'Gamma Alpha',
        'Gamma Beta',
        'Alpha Beta Gamma',
        'Alpha Gamma Beta',
        'Beta Alpha Gamma',
        'Beta Gamma Alpha',
        'Gamma Alpha Beta',
        'Gamma Beta Alpha')
  </code></pre>
  
  <p>Note: The answer I'm looking for should include <em>all combinations and all different arrangements</em>. For example: <strong>'Alpha Beta'</strong> and <strong>'Beta Alpha'</strong> are 2 different strings and both should be in the output array.</p>
  
  <p>Thanks in advance</p>