How to add the same key values of the two functions to form a new array. $ T1 = Array & nbsp; (& nbsp; [0] & nbsp ;=& gt; & nbsp; 1320 & nbsp; [1] & nbsp ;=& gt; & nbsp; 990 & nbsp; [2] & nbsp; = & gt; & nbsp; 895 & nbsp; [3] & nbsp; = & gt; & how does nbsp add the same key values of the two functions to form a new array.
$ T1 = Array ([0] => 1320 [1] => 990 [2] => 895 [3] => 790 [4] => 775 [5] => 745 [6] => 740 [7] => 680 [8] => 665 [9] => 535)
$ T2 = Array ([0] => Nanchang [1] => Ganzhou [2] => Ji 'an [3] => Jiujiang [4] => Nanchang [5] => jiujiang [6] => Pingxiang [7] => outside the province [8] => Nanchang [9] => Jiujiang)
$ T1 and $ t2 have the same length and their values correspond to each other,
For example
[0] = & gt; 1320
[0] => Nanchang
The number representing Nanchang is 1320. now I want to add the same values in $ t2.
For example, Nanchang
[0] = & gt; 1320
[0] => Nanchang
---------------------
[4] = & gt; 775
[4] => Nanchang
-----------------
[8] = & gt; 665
[8] => Nanchang
How to add the three numbers.
Form the following array:
$ T3 = Array ([2760] => Nanchang [990] => Ganzhou [895] => Ji 'an [2070] => Jiujiang [740] => Pingxiang [680] => outside the province )?
If you use the array_combine function, consider the case where the same key name is ignored.
Share :? 1320? [1]? =>? 990? [2]? =>? 895? [3]? =>? 790? [4]? =>? 775? [5]? =>? 745? [6]? =>? 7 .. 'data-pics = ''>
------ Solution --------------------
$ T1 = array (0 => 1320, 1 => 990, 2 => 895, 3 => 790, 4 => 775, 5 => 745, 6 => 740, 7 => 680, 8 => 665, 9 => 535 );
$ T2 = array (0 => 'nanchang ', 1 => 'ganzhou', 2 => 'Ji 'an ', 3 => 'jiujiang', 4 => 'nanchang ', 5 => 'jiujiang ', 6 => 'pingxiang', 7 => 'off-provincial ', 8 => 'nanchang', 9 => 'jiujiang ');
Foreach ($ t2 as $ I =>$ k) @ $ t3 [$ k] + = $ t1 [$ I];
$ T3 = array_flip ($ t3 );
Print_r ($ t3 );
Array ([2760] => Nanchang [990] => Ganzhou [895] => Ji 'an [2070] => Jiujiang [740] => Pingxiang [680] => outside the province)
------ Solution --------------------
No way. your solution is inherently inadequate!