array_merge() and + operator : array_merge « Data Structure « PHP






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

1.Appending One Array to Another
2.Using array_merge() and the + operator with associative arrays as well
3.array_merge
4.array_merge( ) function combines two or more arrays by renumbering numerical indexes and overwriting string indexes
5.array_merge( ) retains array keys when possible.
6.array_merge() example
7.array_merge() function merges 1 to N arrays together
8.obtaining the union of two arrays