Skip to content

Instantly share code, notes, and snippets.

@ahmeti
Last active May 14, 2017 21:25
Show Gist options
  • Save ahmeti/878cea6940a4d4f14de551d12d0652e1 to your computer and use it in GitHub Desktop.
Save ahmeti/878cea6940a4d4f14de551d12d0652e1 to your computer and use it in GitHub Desktop.
combination.php
<?php
$refinements=array(
'Type' => array(
'Toppe',
'Bukser_og_Jeans'
),
'Size' => array(
'Extra_small',
'Small'
),
'Colour' => array(
'Rod'
)
);
$data=[];
$iter = 0;
while (1) {
$num = $iter++;
$pick = array();
foreach ($refinements as $refineGroup => $groupValues) {
$r = $num % count($groupValues);
$num = ($num - $r) / count($groupValues);
$pick[] = $groupValues[$r];
}
if ($num > 0) {
break;
}
//print join(', ', $pick)."<br>";
$data[]=$pick;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment