If you understand that the array is actually a map, I think you'll understand why Array_merge did it.
Merging arrays in PHP is divided into two cases
1, if the two arrays have the same string key name:
<?PHPHeader(' content-type:text/html; Charset=utf8 '); $book 1=Array(' Linux ' = ' Linux server configuration and Management ', ' php ' = ' PHP programming ')); $book 2=Array(' Linux ' = ' Server configuration and Management ', ' jsp ' = ' PHP ')); $result=Array_merge($book 1,$book 2); Print_r($result); //Array ([Linux] = server configuration and management [PHP] + PHP programming [JSP] + PHP)?>
Note: The latter will replace the former, it is normal, the health value can only have one. However, if you are using array_merge_recursive (), you can persist and make a subarray exist. such as:
<? PHP header (' content-type:text/html; Charset=utf8 '); $book 1 = Array (' Linux ' = ' Linux server configuration and Management ', ' php ' = ') PHP program Design '); $book 2 = Array (' Linux ' = ' Server configuration and Management ', ' jsp ' = ' PHP '); $result = array_merge_recursive ($book 1, $book 2); Print_r ($result);//array ([Linux] = array ([0] = Linux Service Configuration and management of servers [1] + = Server configuration and management) [PHP] + PHP programming [JSP] + PHP)?>
2, if the two arrays have the same numeric key name:
<? PHP header (' content-type:text/html; Charset=utf8 '); $book 1 = Array (' Linux server Configuration and Management ', ' PHP programming '); $book 2 = Array (' Server configuration and Management ', ' PHP '); $result = Array_merge ($book 1, $book 2); Print_r ($result);//array ([0] = = Linux Server configuration and management [1] = PHP programming [2] + = Server configuration and management [3] = PHP)?>
At this point, if the array contains the same numeric key name, then the previous value is not overwritten, but the subsequent key values are incremented sequentially, appended to the back.
Using function Array_merge () to merge arrays in PHP