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

[eluser]Evil Wizard[/eluser]
[quote author="Dam1an" date="1243963231"]Would this not cause a problem when both arrays have the same key (eg both have index 0)? Would you expect to overwrite it, increment the key of one to avoid crash etc?[/quote]
That could be avoided with
Code:
if(!count(array_diff_assoc($array1, $array2)) {
    $array3 = $array1 + $array2
}
If any keys are in both arrays it wont add them together.


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



Theme © iAndrew 2016 - Forum software by © MyBB