There are generally two ways to use PHP for array fusion, one is to add directly with the plus sign, and the other is to add by using the Array_merge function, which is a bit different:
1. The natural index in the array will not be reset
2. In the addition method, the values in the added array are not overwritten
The natural index in the 3.merge function will be reset
4.merge function, does not matter by the merge and the merge relationship, the more the array parameter, its value, will overwrite the previous array parameter same key value
Example:
Array 1:
$arr 1 = Array (
=> ' valueof10 ',
=> ' valueof11 ', ' key1
' => ' dataofkey1 ', ' Key2 ' => ')
Dataofkey2 ',
' array ' => array (
' Key1 ' => 1,
' key2 ' => ' abc ',
' Key3 ' => array (
1, 2, ') Name ' => ' Peter '),)
;
Array 2:
$arr 2 = Array (
=> ' Newvalueof10 ', one
=> ' newvalueof11 ',
' key1 ' => ' newdataofkey1 ', ' key3 '
= > ' Newdataofkey3 ',
' array ' => array (
' Key1 ' => 2, ' Key2 ' => ' defg ', ' Key3 ' =>
Array (
1, 2, ' name ' => ' Jonathan ', ' gender ' => ' Male '),)
;
Results comparison:
Array (size=6) => string ' Valueof10 ' (length=9) => string ' valueof11 ' (length=9) ' Key1 ' => string ' data
Ofkey1 ' (length=10) ' Key2 ' => string ' Dataofkey2 ' (length=10) ' array ' => array (size=3) ' key1 ' => int 1 ' Key2 ' => string ' abc ' (length=3) ' Key3 ' => Array (size=3) 0 => int 1 1 => int 2 ' Nam E ' => string ' Peter ' (length=5) ' Key3 ' => string ' Newdataofkey3 ' (length=13) array (size=8) 0 => string ' valu Eof10 ' (length=9) 1 => string ' valueof11 ' (length=9) ' Key1 ' => string ' newdataofkey1 ' (length=13) ' Key2 ' => St Ring ' Dataofkey2 ' (length=10) ' array ' => array (size=3) ' key1 ' => int 2 ' key2 ' => string ' DEFG ' (length =4) ' Key3 ' => Array (size=4) 0 => int 1 1 => int 2 ' name ' => string ' Jonathan ' (length= 8) ' Gender ' => string ' Male ' (length=4) 2 => string ' Newvalueof10 ' (length=12) 3 => string ' newvalueof11 '
(length=12) ' Key3 ' =>
String ' Newdataofkey3 ' (length=13)