1

I have two array one is 1 to 5 number of cards and four colors of cards

$No = array('1','2','3','4','5');
$Color = array('K','L','F','C');

And i want all combination of number to color, number is unique at time, the output is like following sample two combination,Thanks in advance

  Array(
    1-K
    2-K
    3-K
    4-K
    5-K
    1-F
    2-F
    3-F
    4-F
    5-F
    )
Mayur
  • 227
  • 1
  • 8

1 Answers1

2

Use nested loops:

$result = array();
foreach ($No as $n) {
    foreach ($Color as $c) {
        $result[] = "$n-$c";
    }
}
Barmar
  • 741,623
  • 53
  • 500
  • 612
  • Thanks, Barmar that is not actually i want, This result only produce 20 of element but it will should produce (1024) 4*4*4*4*4=(1024) – Mayur Jan 05 '15 at 03:22
  • There are only 20 different combinations: 5 cards * 4 colors. It's not exponential. – Barmar Jan 05 '15 at 05:46