Good evening (middle-european time).
Although my question could be a bit embarassing (because it may be sooo easy) I'm asking you. I apologize in advance but i've been coding for about 10 hours today and need to get this last thing done.
So, is there an array function - honestly i searched for about an hour - in php that somehow does array_merge, comparing the values, ignoring the keys. I think array_unique(array_merge($a, $b)); must be working, however I believe there is a nicer way to do this.
eg.
$a = array(0 => 0, 1 => 1, 2 => 2);
$b = array(0 => 2, 1 => 3, 2 => 4);
resulting in:
$ab = array(0 => 0, 1 => 1, 2 => 2, 3 => 3, 4 => 4);
Please note that I don't care about the keys in $ab, however it would be nice if they were ascending, starting at 0 to count($ab)-1.
Thanks in advance.
array_unique(array_merge($a, $b))
is actually a pretty elegant solution. – Ben Lee Jan 11 '11 at 17:50array_merge
will overwrite. – Will Jan 11 '11 at 17:52