I use array_merge function for merging two arrays. In most case it works properly
$x = array_merge(array('a' => 'x', 'b' => 'x'), array('b' => 'y', 'c' => 'y'));
var_dump($x);
// array(3) { ["a"]=> string(1) "x" ["b"]=> string(1) "y" ["c"]=> string(1) "y" }
But for numeric case it returns unexpected result
$x = array_merge(array('1' => 'x', '2' => 'x'), array('2' => 'y', '3' => 'y'));
var_dump($x);
// array(4) { [0]=> string(1) "x" [1]=> string(1) "x" [2]=> string(1) "y" [3]=> string(1) "y" }
How to prevent renumbering of indexes? There is way to merge two arrays by base php functions without renumbering of numeric indexes?