obtaining the union of two arrays
<?php
function array_display($array, $pre=FALSE) {
$tag = $pre ? 'pre' : 'p';
printf("<%s>%s</%s>\n", $tag, var_export($array, TRUE), $tag);
}
$arr5 = array(1 => 'x', 2 => 'y', 3 => 'z');
$arr1 = array(1 => 'x', 2 => 'y', 3 => 'z');
array_display(array_merge($arr1, $arr5), TRUE);
array_display($arr1 + $arr5, TRUE);
?>
Related examples in the same category