Code: Select all
$categories = array();
array_push($categories, array(1,2,3,4,5,6,7));
array_push($categories, array("white", "blue", "red", "green", "purple"));
array_push($categories, array("one", "two", "three", "four"));Code: Select all
function allPosibleCombinations($categories)
{
$counter = array();
for($j=0; $j<count($categories); $j++)
{
$counter[$j] = 0;
}
$paf = 0;
for($i=0; $i<count($categories); $i++)
{
echo "#i=".$i."<br>";
for($j=$i; $j<count($categories); $j++)
{
echo "#j=".$j."<br>";
for($k=$i; $k<count($categories[$j]); $k++)
{
$paf ++;
$echoStr = $paf.">>";
for($l=0; $l<count($categories); $l++)
{
$echoStr .= $categories[$l][$counter[$l]];
}
echo $echoStr."<br>";
$counter[$j]++;
}
$counter[$j] = 0;
}
}
}