Florian Lemaitre wrote: > Le 29/05/2012 14:45, Gary a écrit : >> Okay, let's assume I have three "things", A, B, and C. I need to > produce >> an array with a list of all possible combinations of them, however > many >> there might be in those combinations: e.g. A, B, C, D, AB, AC, AD, BC, >> ABC (not sure if I've missed any!). > Enjoy ! > > function combinations($letters) { > $combinations = array(array()); > foreach ($letters as $letter) { > foreach ($combinations as $combination) { > $combinations[] = array_merge($combination, array($letter)); > } > } > return $combinations; > } :-) Looks to do pretty much exactly what I want, thanks! The key is the array_merge, I guess :) Let's just say I wrote a *lot* more code than that :") -- Gary Please do NOT send me 'courtesy' replies off-list. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php