Array ([0] = = Array ([id] = 9 [Ti] = Me) [1] = = Array ([id] = [ti] + =) [2] = = Array ([ID] = = [Ti] = in) [3] = = Array ([id] = [ti] = country))
This translates into a one-dimensional array id as key, the conversion I would, but encountered the same on the merge how to do?
If you get a one-dimensional array, combine the resulting one-dimensional array with the following, and replace the value if key is equal;
Array ([7] = love [8] = = I [9] = = [Ten]--33333 [one] = [[ALL] = China]
There are two problems encountered in the current practice array, please master guidance. After a quick day, or failed ... -_-
Reply to discussion (solution)
$a = Array ( ' id ' = = 9, ' ti ' = ' i '), array (' id ' = ' = ', ' ti ' = ') ', array (' ID ' =& Gt One, ' ti ' = ' in '), Array (' id ' = = ', ' ti ' = ') '), $res = Array (), foreach ($a as $r) { if (isset ($res [$r [ ' ID '])) $res [$r [' ID ']]. = $r [' ti ']; else $res [$r [' id ']] = $r [' Ti '];} Print_r ($res);
Array ( [9] = = i [ten] [all] [one] = China)
$a = Array ( ' id ' = = 9, ' ti ' = ' i '), array (' id ' = ' = ', ' ti ' = ') ', array (' ID ' = = ', ' ti ' = ' in '), Array (' id ' = = ', ' ti ' + ') '), $res = Array (); foreach ($a as $r) { if (Isse T ($res [$R [' ID ']]) $res [$r [' ID ']]. = $r [' ti ']; else $res [$r [' id ']] = $r [' Ti '];} Print_r ($res);
Array ( [9] = = i [ten] [all] [one] = China)
Moderator sorry I also want to ask $res[$r [' id ']. = $r [' ti ']; what is the symbol used for? If you merge $res with the following array, the same key is encountered to replace his value. Can you do that?
Array ([7] = love [8] = = I [9] = = [Ten]--33333 [one] = [[ALL] = China]
Haha, has been using Array_merge () merged, the original directly with the + number on the line ....