<?php
function createAttributeCollections($pricingAttributes = null, $permutation = array()){
//permutation result
if (empty($pricingAttributes)) {
return implode(',', $permutation );
//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'));
foreach($results as $result){
echo $result.'<br>';
}
preferences:
47.83 ms | 402 KiB | 5 Q