Suppose I have an associative array with keys that are alphabetic string, and if I merge something to this array, It will merge successfully without reindexing like
$arr1 = array('john'=>'JOHN', 'marry'=>'Marry');
$arr1 = array_merge(array('78'=>'Angela'),$arr1);
print_r($arr1);
then this will correctly merge new component to array and its output will be
Array
(
[0] => Angela
[john] => JOHN
[marry] => Marry
)
But when I tried same thing like this
$arr1 = array('34'=>'JOHN', '04'=>'Marry');
$arr1 = array_merge(array('78'=>'Angela'),$arr1);
print_r($arr1);
then its output is like this
Array
(
[0] => Angela
[1] => JOHN
[04] => Marry
)
Can anyone describes this scenario..... Also I want my array to be like this after merging..
Array
(
[78] => Angela
[34] => JOHN
[04] => Marry
)
How can I Achieve that??