这应该可以解决问题:
<?$data[]=array('shirt');$data[]=array('red','yellow','black');$data[]=array('small','medium','large');$combos=possible_combos($data);//calculate all the possible comobos creatable from a given choices arrayfunction possible_combos($groups, $prefix='') { $result = array(); $group = array_shift($groups); foreach($group as $selected) { if($groups) { $result = array_merge($result, possible_combos($groups, $prefix . $selected. ' ')); } else { $result[] = $prefix . $selected; } } return $result;}echo count($combos) . "n";print_r($combos);已测试:http :
//www.ideone.com/NZE5S



