array_merge() and + operator
<?php
function array_display($array, $pre=FALSE) {
$tag = $pre ? 'pre' : 'p';
printf("<%s>%s</%s>\n", $tag, var_export($array, TRUE), $tag);
}
$arr4 = array(10 => 'a', 11 => 'b', 12 => 'c');
$arr1 = array(1, 2, 3);
array_display(array_merge($arr1, $arr4), TRUE);
array_display($arr1 + $arr4, TRUE);
?>
Related examples in the same category