Php array combination $ set = array ('A', 'B', 'C', 'D ');
How to combine arrays? the output result is
A
B
C
B
AB
Ac
Ad
Bc
Bd
Reply to discussion (solution)
$ Set = array ('A', 'B', 'C', 'D'); $ res = $ set; for ($ I = 0, $ p = 1; $ I
Array
(
[0] =>
[1] => B
[2] => c
[3] => d
[4] => AB
[5] => bc
[6] => cd
)
$ Set = array ('A', 'B', 'C', 'D'); $ res = $ set; for ($ I = 0, $ p = 1; $ I
Array
(
[0] =>
[1] => B
[2] => c
[3] => d
[4] => AB
[5] => bc
[6] => cd
)
The outputs of the moderator are different from those of the landlord. I am not sure how the moderator combines the outputs of this array. my solution is as follows: no cd output is needed here.
array (size=10) 0 => string 'a' (length=1) 1 => string 'b' (length=1) 2 => string 'c' (length=1) 3 => string 'd' (length=1) 4 => string 'ab' (length=2) 5 => string 'ac' (length=2) 6 => string 'ad' (length=2) 7 => string 'bc' (length=2) 8 => string 'bd' (length=2) 9 => string 'cd' (length=2)
$set = array('a','b','c','d');$arr=array();for($j=0;$j
$v){ for($i=$k;$i<=(3-$v);$i++){ if($v==$set[$i]) continue; $arr[]=$v.$set[$i]; }}print_r($arr);
Array( [0] => a [1] => b [2] => c [3] => d [4] => ab [5] => ac [6] => ad [7] => bc [8] => bd [9] => cd)