There are two situations for merging arrays in PHP
1. If the two arrays have the same string key name:
$book1 = array(linux=>linux server configuration and Management,php=>PHP programming);
$book2 = array(linux=>Server configuration and management,jsp=>PHP);
$result = array_merge($book1,$book2);
print_r($result);
?>
The output is:
Array ( [linux] => Server Configuration and Management [php] => PHP Programming [jsp] => ; PHP )
indicates that the latter will replace the former. But if array_merge_recursive() is used, it can be retained and exist as a subarray. For example:
$book1 = array(linux=>linux server configuration and management,php=>PHP programming);
$book2 = array(linux=>server configuration With management, jsp=>PHP);
$result = array_merge_recursive($book1,$book2);
print_r($result);
?>
The output is:
Array ( [linux] => Array ( [0] => linux server configuration and management [1] => server configuration and management) [php] => PHP programming [jsp] => PHP )
2. If the two arrays have the same numerical key name:
$book1 = array (linux server configuration and management, PHP programming);
$book2 = array(Server Configuration and Management, PHP);
$result = array_merge($book1,$book2);
print_r($result);
?>
The result is:
Array ([0] => linux server configuration and management[1] => PHP programming[2] => Server configuration and management[3] => PHP)