title: php array_merge associative arrays
body: <p>I'm trying to prepend an item to the beginning of an associative array.  I figured the best way to do this is to use array_merge, but I'm having some odd consequences.  I get the id and Name of products from a mysql database, and it gets returned as an associative array, like this (not the actual data coming back, but sample data for this question that represents what the data looks like approximately):</p>
  
  <pre><code>$products = array (1 =&gt; 'Product 1', 42 =&gt; 'Product 42', 100 =&gt; 'Product 100');
  </code></pre>
  
  <p>this is getting sent to an html helper to create a dropdown that associates the key with the  value, and the value of the array item gets set as the text in the drop down select control.  I need the first item to be something like "Please Select" with a key of 0, so I did this:</p>
  
  <pre><code>$products = array_merge(array(0 =&gt; "Select a product" ), $products);
  </code></pre>
  
  <p>The resulting array looks like this:</p>
  
  <pre><code>array(
    0 =&gt; 'Select a product', 
    1 =&gt; 'Product 1', 
    2 =&gt; 'Product 42', 
    3 =&gt; 'Product 100' 
  );
  </code></pre>
  
  <p>when What I really wanted was not to lose the keys of the associative array.  I was told that you can properly use array_merge with associative arrays in the manner I tried, however, I believe because my keys are <strong>ints</strong> that it is not treating the array as a true associative array, and compressing them as illustrated above.  </p>
  
  <p>The question is:  Why is the array_merge function changing the keys of the items?  can I keep it from doing this?  OR is there another way for me to accomplish what I'm trying to do, to add the new item at the beginning of the array?</p>