3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function createAttributeCollections($pricingAttributes = null, $permutation = array()){ //permutation result if (empty($pricingAttributes)) { echo implode(',', $permutation ).'<br>'; //permutation } else { //permutation loop for ($i = count($pricingAttributes) - 1; $i >= 0; --$i) { $newpricingAttributes = $pricingAttributes; $newPermutations = $permutation; list($foo) = array_splice($newpricingAttributes, $i, 1); array_unshift($newPermutations, $foo); createAttributeCollections($newpricingAttributes, $newPermutations); } } } $results = createAttributeCollections(array('A','B','G','U'));
based on eZ4Uc
Output for 4.3.0 - 7.2.0
A,B,G,U<br>B,A,G,U<br>A,G,B,U<br>G,A,B,U<br>B,G,A,U<br>G,B,A,U<br>A,B,U,G<br>B,A,U,G<br>A,U,B,G<br>U,A,B,G<br>B,U,A,G<br>U,B,A,G<br>A,G,U,B<br>G,A,U,B<br>A,U,G,B<br>U,A,G,B<br>G,U,A,B<br>U,G,A,B<br>B,G,U,A<br>G,B,U,A<br>B,U,G,A<br>U,B,G,A<br>G,U,B,A<br>U,G,B,A<br>