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

[eluser]TheFuzzy0ne[/eluser]
OK, an example:
Code:
$arr1 = array(
    '1' => 'val 1',
    '2' => 'val 2',
);

$arr2 = array(
    '10' => 'val 10',
    '11' => 'val 11',
);

When there are merged together, I should have an array like this:

Code:
$arr1 = array(
    '1' => 'val 1',
    '2' => 'val 2',
    '10' => 'val 10',
    '11' => 'val 11',
);

But instead, I get an array like this:

Code:
$arr1 = array(
    '0' => 'val 1',
    '1' => 'val 2',
    '2' => 'val 10',
    '3' => 'val 11',
);

Note: The keys have been reindexed. I'm trying to merge the two together without using a loop, whilst keeping the keys intact.

Thanks again.


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



Theme © iAndrew 2016 - Forum software by © MyBB