Why my php array is over written when they have same Keys
<p>I have a custom PHP function which executes a stored procedure and returns an array:</p>

<pre><code>function test(){
  $in      = array("abc","bcd","efg");
  $result  = mydba-&gt;executestoredprocedure('proc1',$in);
  $arr_sim = array();

  foreach ($result['recordset'] as $rows) {
    if (!empty($rows)) {
      echo $arr_sim[$rows['field1']] = $rows['field2'];
    }
  }

  return $arr_sim;
}
</code></pre>

<p>In the above function <code>$arr_sim</code> is returning the number of items correctly when the <code>rows["field1"]</code> values are different. If the <code>rows["field1"]</code> values are the same then it is overwriting the first value and returning only the last one. How can I overcome this?</p>

<pre><code>array ( [chicago] =&gt; 'sears', [rochester] =&gt; 'liberty' )
</code></pre>

<p>If the <code>$arr_sim</code> contains these items then it is returned correctly. Because the keys are different.</p>

<pre><code>array ( [chicago] =&gt; 'MCD', [chicago] =&gt; 'TACOBELL' )
</code></pre>

<p>If the <code>$arr_sim</code> contains these items then it is not returned correctly. Because the keys are the same, "chicago".</p>
