<?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','S'));
preferences:
48.9 ms | 402 KiB | 5 Q