There are multiple arrays. how many combinations can be calculated and obtained?

Source: Internet
Author: User
There are multiple arrays. how many combinations can be calculated and obtained ?? The count values in arrays A, B, C, and D are not necessarily the same. The combination sequence is fixed & nbsp; A [rand] & nbsp; + & nbsp; B [rand] & nbsp; + & nbsp; C [rand] & nbsp; + & nbsp; D [rand] & nbs has multiple arrays. how many combinations can be calculated and obtained ??
Array A, B, C, D
The count in the table is not necessarily the same.
The combination order is fixed. A [rand] + B [rand] + C [rand] + D [rand] = no repeated strings.
How can I obtain the maximum number of combinations and no repeated strings ?? Share:
------ Solution --------------------
This post was last edited by xuzuning at 23:59:51 on = count (A) * count (B) * count (C) * count (D)

$a = array('a1', 'a2');
$b = array('b1', 'b2');
$c = array('c1', 'c2', 'c3');
$d = array('d1', 'd2', 'd3');

print_r(func($a, $b, $c, $d));

function func() {
  $d = func_get_args();
  $r = array_shift($d);
  while($d) {
    $t = array();
    foreach(array_shift($d) as $x)
      foreach($r as $y) $t[] = $y . $x;
    $r = $t;
  }
  return $r;
}
Array
(
[0] => a1b1c1d1
[1] => a2b1c1d1
[2] => a1b2c1d1
[3] => a2b2c1d1
[4] => a1b1c2d1
[5] => a2b1c2d1
[6] => a1b2c2d1
[7] => a2b2c2d1
[8] => a1b1c3d1
[9] => a2b1c3d1
[10] => a1b2c3d1
[11] => a2b2c3d1
[12] => a1b1c1d2
[13] => a2b1c1d2
[14] => a1b2c1d2
[15] => a2b2c1d2
[16] => a1b1c2d2
[17] => a2b1c2d2
[18] => a1b2c2d2
[19] => a2b2c2d2
[20] => a1b1c3d2
[21] => a2b1c3d2
[22] => a1b2c3d2
[23] => a2b2c3d2
[24] => a1b1c1d3
[25] => a2b1c1d3
[26] => a1b2c1d3
[27] => a2b2c1d3
[28] => a1b1c2d3
[29] => a2b1c2d3
[30] => a1b2c2d3
[31] => a2b2c2d3
[32] => a1b1c3d3
[33] => a2b1c3d3
[34] => a1b2c3d3
[35] => a2b2c3d3
)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.