How can we add the same key values of these two functions to form a new array ;? Php $ a1 11111, 22222,;,; semicolon extended infinitely $ a explode (;, $ a1); $ b1; semicolon extended infinitely, how to add the same key values of the two functions together to form a new array
Output:
Array ( [0] => 10,20,30,40 [1] => 1,2,3,4 ) Array ( [0] => 11111 [1] => 22222 )
What I want to achieve is:
Array ( [0] => 10,20,30,40,11111 [1] => 1,2,3,4,22222)
I tried array_merge_recursive () and it didn't work. could you please help me! I have been studying for several days.
------ Solution --------------------
$ A1 = '10, 20, 30, 40; 1, 2, 3, 4 '; // expanded infinitely with a semicolon $ a = explode ('; ', $ a1); $ b1 = '2017; 22222 '; // The semicolon is infinitely extended. it can be aligned with $ a1 and superimposed $ B = explode ('; ', $ b1); $ c = array_map (null, $, $ B); print_r ($ c );
Array( [0] => Array ( [0] => 10,20,30,40 [1] => 11111 ) [1] => Array ( [0] => 1,2,3,4 [1] => 22222 ))
------ Solution --------------------
$ A1 = '10, 20, 30, 40; 1, 2, 3, 4 '; // expanded infinitely with a semicolon $ a = explode ('; ', $ a1); $ b1 = '2017; 22222 '; // The semicolon is infinitely extended. it can be aligned with $ a1 and superimposed $ B = explode ('; ', $ b1); $ c = array (); foreach ($ a as $ key => $ value) {$ c [] = $ value. ",". $ B [$ key];} echo 'Array ([0] => 10, 20, 30, 40, 11111 [1] => 22222)
The preceding figure shows how to add the same key values of the two functions to form the content of a new array. For more information, see PHP Chinese website (www.php1.cn )!