Too many arrays! My head is exploding!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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!). Normally I'm pretty good at working
this stuff out, but to be honest I'm struggling with this one, at least
to do it in any kind of elegant way. Does anyone have any ideas?

Idealy what I'd like is a multidimensional array depending on the number
of "things" in the combination. Something like:
array(2) {
  [0]=>
  array(3) {
    [0]=>
    array(1) {
      ["name"]=>
      string(7) "A"
    }
    [1]=>
    array(2) {
      ["name"]=>
      string(5) "B"
    }
    [2]=>
    array(2) {
      ["name"]=>
      string(4) "C"
    }
  }
  [1]=>
  array(...) {
    [0]=>
    array(2) {
      ["name"]=>
      string(13) "A+B"
    }
    [1]=>
    array(2) {
      ["name"]=>
      string(12) "A+C"
    }
(etc.)


--
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



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux