Welcome Guest, Not a member yet? Register   Sign In
Quick question - merging two or more arrays without reindexing
#10

[eluser]Dam1an[/eluser]
Looking on the php docs (here) that only seems to work one way :-S

Code:
<?php
$array1 = array('blue'  => 1, 'red'  => 2, 'green'  => 3, 'purple' => 4);
$array2 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan'   => 8);

var_dump(array_diff_key($array1, $array2));
?>
Results in
Code:
array(2) {
  ["red"]=>
  int(2)
  ["purple"]=>
  int(4)
}
Whereas you'd want Yellow and Cyan from the second array in this case


Messages In This Thread
Quick question - merging two or more arrays without reindexing - by El Forum - 06-02-2009, 07:41 AM



Theme © iAndrew 2016 - Forum software by © MyBB