title: How to enumerate all possible combinations of elements
body: <p>I want to enumerate all possible combinations of elements array. For example: I have array:</p>
  
  <pre><code>$r = ('a1','a2','a3' ...).
  </code></pre>
  
  <p>I want to print all combinations of element arrays:
  a1a2, a1a3, a1a2a3, etc .
  where
  a1a2 != a2a1, a1a2a3 != a1a3a2 ...</p>