联合运算符的行为与我最初想象的有所不同。它基于数组的键实现联合(某种形式的联合),而不是基于值。
例如
<?php
$a = array('one','two');
$b=array('three','four','five');
//不是数组值的联合
echo '$a + $b : ';
print_r ($a + $b);
//数组值的联合
echo "array_unique(array_merge($a,$b)):";
//摘自 http://oreilly.com/catalog/progphp/chapter/ch05.html
print_r (array_unique(array_merge($a,$b)));
?>
//输出
$a + $b : Array
(
[0] => one
[1] => two
[2] => five
)
array_unique(array_merge(Array,Array)):Array
(
[0] => one
[1] => two
[2] => three
[3] => four
[4] => five
)