Demonstrate the Difference Between the Array '+' Operator and a True Array Union
<?php
$first = array('e', 'h', 'r', 'j', 'b');
$last = array('w', 'e', 'c');
$plus_union = $last + $first;
echo '<p>';
foreach ($plus_union as $v) { echo "{$v} "; }
echo "</p>\n";
$union = array_unique(array_merge($first, $last));
echo '<p>';
foreach ($union as $v) { echo "{$v} "; }
echo "</p>\n";
?>
Related examples in the same category