Detailed description of the PHP function array_merge. PHP merges arrays into two types: 1. if the two arrays have the same string key name :? Php $ book1array (phplinux server configuration and management, phpPHP program design); $ book2 PHP combines arrays into two cases
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 );
?>
Output:
Array ([linux] => server configuration and management [php] => PHP programming [jsp] => PHP)
Note: the latter will replace the former. However, if array_merge_recursive () is used, it can be retained and used as a subarray. For example:
$ Book1 = array (linux => linux server configuration and management, php => PHP programming );
$ Book2 = array (linux => server configuration and management, jsp => PHP );
$ Result = array_merge_recursive ($ book1, $ book2 );
Print_r ($ result );
?>
Output:
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 value 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)
Limit 1. if the two arrays have the same string key name :? Php $ book1 = array (linux = linux server configuration and management, php = PHP programming); $ book2...