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 )."\n"; //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 JX30s
Output for 4.3.0 - 7.2.0
A,B,G,U B,A,G,U A,G,B,U G,A,B,U B,G,A,U G,B,A,U A,B,U,G B,A,U,G A,U,B,G U,A,B,G B,U,A,G U,B,A,G A,G,U,B G,A,U,B A,U,G,B U,A,G,B G,U,A,B U,G,A,B B,G,U,A G,B,U,A B,U,G,A U,B,G,A G,U,B,A U,G,B,A