Array_merge() problem

Hi, I am trying to understand the array_merge(…)
I got the following definition:

If the input arrays have the same string keys, then the later value for that key will overwrite the previous one. If, however, the arrays contain numeric keys, the later value will not overwrite the original value, but will be appended.

I am using numeric based string keys but my program is behaving in the same way as the numeric based keys.

<?php 
$questions = array (  
    '10' => 'Yes',  
    '11' => 'No'  ,
    '12' => 'Yes',  
    '13' => 'No',  
    '14' => 'Yes',  
    '15' => 'No'  
); 

$comments = 
array (  
    '10' => 'comment',  
    '11' => 'comment' , 
    '12' => 'comment'  ,
    '13' => 'comment'  ,
    '14' => 'comment'  ,
    '15' => 'comment'  
);

$res = array_merge($questions, $comments);


print_r($res);
?>

The output is:
Array ( [0] => Yes [1] => No [2] => Yes [3] => No [4] => Yes [5] => No [6] => comment [7] => comment [8] => comment [9] => comment [10] => comment [11] => comment )

I am expecting the answer like:
[10] => comment [11] => comment [12] => comment[13] => comment[14] => comment[15] => comment

Similar to the output of following program:

<?php $str1 = array('A'=> 12, 'B' => 5, 'C' => 8); $str2 = array('A' => 15, 'D' => 10); $newArray3 = array_merge($str1, $str2); print_r($newArray3); ?>

Output is:
Array ( [A] => 15 [B] => 5 [C] => 8 [D] => 10 )

Some body please guide me why string numeric keys are not behaving like strings?
Zulfi.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.