Home  >  Article  >  Backend Development  >  China Unicom 10010 Online Business Hall Share a simple method of merging arrays using the plus sign in PHP

China Unicom 10010 Online Business Hall Share a simple method of merging arrays using the plus sign in PHP

PHP中文网
PHP中文网Original
2016-07-29 08:44:211557browse

                  Code:

Copy code The code is as follows:


$a = array('a' => 'a', 'b' => 'b');
$b = array('c' => 'c', 'd' => 'd');
$c = $a + $b;
print('

'); 
print_r($c); 
print('

');
?>


Result:

Copy code The code is as follows:


Array
(
[a] => a
[b] => b
[c] => c
[d] => d
)


Note: There is still a difference between the plus sign and the array_merge() function, that is, when using the plus sign to merge arrays, if there are keys with the same name between the arrays, then the key values ​​corresponding to the previous arrays will be retained. The array_merge() function is just the opposite.

The above has introduced a simple method of merging arrays in PHP using the plus sign in China Unicom 10010 Online Business Hall, including the content of China Unicom 10010 Online Business Hall. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn