array_merge( ) retains array keys when possible. : array_merge « Data Structure « PHP






array_merge( ) retains array keys when possible.

 
<?
    $arr1 = array("Paul"=>25, "I"=>38, "Nick"=>27);
    $arr2 = array("I"=>27, "Paul"=>38);

    print "Merge:\n";
    var_dump(array_merge($arr1, $arr2));
?>
  
  








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() and + operator
6.array_merge() example
7.array_merge() function merges 1 to N arrays together
8.obtaining the union of two arrays