Array (0 = = Array (' id ' = ' + ', ' title ' = ' A ', ' type ' = ' 1 ', ' bian ' = ' 1 '),
1 = = Array (' id ' = ' + ', ' title ' = ' A ', ' type ' = ' 1 ', ' Bian ' =>2),
2 = = Array (' id ' = ' = ', ' title ' = ' B ', ' type ' = ' 2 ', ' bian ' = ' 1 '),
3 = = Array (' id ' = ' = ', ' title ' = ' C ', ' type ' = ' 2 ', ' bian ' = ' 2 '),
)
When type=1 removes the same ID repetition and key becomes the ID, when type=2 the key becomes the Id_bian form, eventually turns into the following array
Array (0 = = Array (' + ' = ', ' 11_1 ' = ' = ', ' 11_2 ' = ') ')
Then merge with the following array
Array (0 + = array (' Ten ' = ' 1 ', ' 11_2 ' = ' 1 '),
1 = = Array (' Ten ' = ' 1 ', ' 11_2 ' = ' 1 '),
2 = = Array (' 11_1 ' = ' 1 ', ' 11_2 ' = ' 1 '),
3 = = Array (' Ten ' = ' 2 ', ' 11_2 ' = ' 1 '),
)
Eventually get
Array (0 + = array (' + ' = ' 1 ', ' 11_1 ' = ' = ', ' 11_2 ' = ' 1 '),
1 = = Array (' + ' = ' 1 ', ' 11_1 = ', ' 11_2 ' = ' 1 '),
2 = = Array (' ten ' = ' = ', ' 11_1 ' = ' 1 ', ' 11_2 ' = ' 1 '),
3 = = Array (' Ten ' + ' 2 ', ' 11_1 ' = ' = ', ' 11_2 ' = ' 1 '),
)
Reply to discussion (solution)
$a = Array (0 = = Array (' id ' = ' + ', ' title ' = ' A ', ' type ' = ' 1 ', ' Bian ' =& gt; ' 1 '), 1 = = array (' id ' = ' + ', ' title ' = ' A ', ' type ' = ' 1 ', ' bian ' = ' 2 '), 2 = = Array (' id ' = ' 1 ') 1 ', ' title ' = ' B ', ' type ' = ' 2 ', ' bian ' = ' 1 '), 3 = = Array (' id ' = ' = ', ' title ' = ' C ', ' type ' = ' = ') 2 ', ' bian ' + ' 2 '), $b = Array (0 = = Array (' 1 ', ' 11_2 ' = ' 1 '), 1 = = Array (' + ' = ' 1 ', ' 11 _2 ' + ' 1 '), 2 = = Array (' 11_1 ' = ' 1 ', ' 11_2 ' = ' 1 '), 3 = = Array (' ' = ' 2 ', ' 11_2 ' = ' 1 '),); $ t = Array (), foreach ($a as $item) {if ($item [' type '] = = ' 1 ') {$t [$item [' id ']] = '; }else $t [$item [' id ']. ' _ '. $item [' bian ']] = ';} $c = Array (); foreach ($b as $v) {$r = array (); foreach ($t as $k = + $n) $r [$k] = @ $v [$k]; $c [] = $r;} Print_r ($c);
Array ( [0] = = Array ( [Ten] = 1 [11_1] = [11_2] = 1 ) [1] = = Array ( C8/>[10] = 1 [11_1] = [ 11_2] = 1 ) [2] = = Array ( [Ten] = [11_1] =& Gt 1 [11_2] + 1 ) [3] = = Array ( [ten] + 2 [11_1] = [11_2] = 1 ) )
$a = Array (0 = = Array (' id ' = ' + ', ' title ' = ' A ', ' type ' = ' 1 ', ' Bian ' =& gt; ' 1 '), 1 = = array (' id ' = ' + ', ' title ' = ' A ', ' type ' = ' 1 ', ' bian ' = ' 2 '), 2 = = Array (' id ' = ' 1 ') 1 ', ' title ' = ' B ', ' type ' = ' 2 ', ' bian ' = ' 1 '), 3 = = Array (' id ' = ' = ', ' title ' = ' C ', ' type ' = ' = ') 2 ', ' bian ' + ' 2 '), $b = Array (0 = = Array (' 1 ', ' 11_2 ' = ' 1 '), 1 = = Array (' + ' = ' 1 ', ' 11 _2 ' + ' 1 '), 2 = = Array (' 11_1 ' = ' 1 ', ' 11_2 ' = ' 1 '), 3 = = Array (' ' = ' 2 ', ' 11_2 ' = ' 1 '),); $ t = Array (), foreach ($a as $item) {if ($item [' type '] = = ' 1 ') {$t [$item [' id ']] = '; }else $t [$item [' id ']. ' _ '. $item [' bian ']] = ';} $c = Array (); foreach ($b as $v) {$r = array (); foreach ($t as $k = + $n) $r [$k] = @ $v [$k]; $c [] = $r;} Print_r ($c);
Array ( [0] = = Array ( [Ten] = 1 [11_1] = [11_2] = 1 ) [1] = = Array ( C8/>[10] = 1 [11_1] = [ 11_2] = 1 ) [2] = = Array ( [Ten] = [11_1] =& Gt 1 [11_2] + 1 ) [3] = = Array ( [ten] + 2 [11_1] = [11_2] = 1 ) )
If you append $t as element in $c, do you want to re-traverse it?
Append Array (' ten ' = ', ' 11_1 ' + ', ' 11_2 ' = ' = ') as $c
I don't know what you mean.
I don't know what you mean.
$a = Array (0 = = Array (' id ' = ' + ', ' title ' = ' A ', ' type ' = ' 1 ', ' bian ' = ' 1 '), 1 = = Array (' ID ' = ' + ', ' title ' = ' A ', ' type ' = ' 1 ', ' bian ' + ' 2 '), 2 = = Array (' id ' = ' = ', ' title ' = ' B ', ' Type ' = ' 2 ', ' bian ' = ' 1 '), 3 = = Array (' id ' = ' = ', ' title ' = ' C ', ' type ' = ' 2 ', ' bian ' = ' 2 '),
); $b = Array (0 = = Array (' + ' = ' 1 ', ' 11_2 ' = ' 1 '), 1 = = Array (' + ' = ' 1 ', ' 11_2 ' = ' 1 '), 2 = = Array (' 11_1 ' = ' 1 ', ' 11_2 ' = ' 1 '), 3 = = Array (' + ' = ' 2 ', ' 11_2 ' = ' 1 '), ); $t = array (); f Oreach ($a as $item) { if ($item [' type '] = = ' 1 ') { $t [$item [' id ']] = '; } else $t [$item [' id ']. ' _ '. $item [' bian ']] = ';} $c = Array (); foreach ($b as $v) { $r = array (); foreach ($t as $k = + $n) $r [$k] = @ $v [$k]; $c [] = $r;} Print_r ($c);
Is that the result of the whole of array A is inserted into the $c, is it not certain to $c in the traversal?
Didn't traverse $c.